belongsToMany( TypeModel::class, 'type_video', 'video_id', 'type_id' ); } public function user() { return $this->hasOne(UserModel::class, 'code', 'uid') ->select(['code','nick','avatar']); } public function perfect() { return $this->hasMany(VideoPerfectModel::class, 'video_id', 'id'); } public function tags() { return $this->hasMany(TypeVideoModel::class, 'video_id', 'id'); } /** * 统一处理0x0的情况. * @param $value * @return string */ public function getResolutionAttribute($value) { if ($value == '0x0') { return '1x1'; } else { return $value; } } }