samedi 15 octobre 2016

Laravel 5 : Displaying the column data of third table from first table where both tables are connected to a second table

I have three tables namely 1.Product 2.Category and 3.Attribute and each category have different attribute name For eg: Mobile has RAM,Processor.All the attribute name are saved in Attribute table .When i want someone to enter the attribute value the attribute name should come from attribute table in the Product table depending upon the categoryname chosen by user. And the key which is similar in all the three tables is Categoryname.

Relationships are as follows

Product Model :

public function categories()
{
    return $this->hasMany(Category::class);
}

public function attributes()
{
    return $this->hasMany(Attribute::class);
}

Category Model :

public function products()
{
    return $this->belongsTo(Product::class);
}
public function attributes()
{
    return $this->hasMany(Attribute::class);
}

Attribute Model :

public function categories()
{
return $this->belongsTo(Category::class);
}

How can i display the attribute name from attribute table in Product table via Category Table



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire