G
G
golemico2017-07-30 14:13:18
Laravel
golemico, 2017-07-30 14:13:18

How to get value for attribute properties in Laravel?

Good afternoon, I have a problem. Now I am making a product catalog, the database structure is as follows:
1. product - products
2. product_attribute - relationship between product and attribute_value
3. attribute_value - attribute properties
4. attribute - name of attributes
In the product model itself, the relationship with attribute properties (3. attribute_value)

public function attribute()
{
    return $this->hasMany('App\Models\ProductAttribute');
}

That's the question itself, how to get the name of the attributes (4. attribute) , since now I only display the properties of the attributes (3. attribute_value) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-07-30
@alexey-m-ukolov

You have a crooked connection. There should be three tables:

  1. Product.
  2. Attribute.
  3. A bundle of products and attributes, along with which the value is stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question