I have requests table that belongs to subcategories tabla wich belongs to categories table, so from Request model how can I get an atribute from categories?
tables
->requests
id
name
subcategory_id
->subcategories
id
name
category_id
->categories
id
name
color
So I need to get color from Request model, I alredy have the tree models created
class Request extends Model
{
public function user()
{
return $this->belongsTo(User::class)->get();
}
public function color()
{
$somemagicstuff;
return $color;
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire