'int', 'sort' => 'int', 'image_id' => 'array', 'link_type' => 'int', 'category_id' => 'int', ]; protected $fillable = [ 'title', 'image_id', 'link', 'link_type', 'category_id', 'status', 'sort', ]; protected $with = ['image', 'category']; /** * 关联图片 * @return HasOne */ public function image(): HasOne { return $this->hasOne(SysFileModel::class, 'id', 'image_id'); } /** * 关联所属分类(link_type=1 时生效) * @return BelongsTo */ public function category(): BelongsTo { return $this->belongsTo(SysCategoryModel::class, 'category_id', 'id'); } }