belongsTo(Category::class, 'category_id', 'id'); } /** * 定义与分类的多对一关系 */ public function websiteCategory() { return $this->belongsTo(WebsiteCategory::class, 'category_id', 'id'); } /** * The attributes that are mass assignable. */ protected array $fillable = []; /** * The attributes that should be cast to native types. */ protected array $casts = []; }