我有属于子类别表的请求表,而子类别表属于类别表,因此如何从请求模型中获取类别的属性?
tables
->requests
id
name
subcategory_id
->subcategories
id
name
category_id
->categories
id
name
color
所以我需要从Request模型中获取颜色,我已经创建了树模型
class Request extends Model
{
public function user()
{
return $this->belongsTo(User::class)->get();
}
public function color()
{
$somemagicstuff;
return $color;
}
}