// +---------------------------------------------------------------------- namespace App\Models; /** * 视频课表单数据-模型 * @author laravel开发员 * @since 2020/11/11 * @package App\Models */ class VideoDatasModel extends BaseModel { // 设置数据表 protected $table = 'videos_datas'; public function getPosterAttribute($value) { return $value ? get_image_url($value) : ''; } public function setPosterAttribute($value) { return $value ? get_image_path($value) : ''; } /** * 分类 * @return \Illuminate\Database\Eloquent\Relations\HasOne */ public function category() { return $this->hasOne(VideoDatasCategoryModel::class, 'id', 'category_id') ->select(['id', 'name', 'pid','icon']); } }