I have category table, attribute table and attribute_value table,
Category:
id | Catgeory Name
Attribute:
id| cat_id | Attribute Name
Attribute Table:
id | attr_id | attr_value
Now i want to Display it like this :
Category Name
Attribute Name 1
Attribute Val 1
Attribute val n
Attribute Name 2
Attribute Val 1
Attribute Val n
..
..
I'm using following model
Attribute:
public function attr_values()
{
return $this->hasMany(AttributeValue::class);
}
Attribute Values :
public function attribute()
{
return $this->belongsTo(Attribute::class);
}
In controller i'm getting data using following:
Category::with(['attribute'])->whereIn('id', $ids)->get();
But i'm unable to get the data attributes that are linked to Category and its attributes Values.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire