Premium Video Tutorial
Premium Members Only
This advanced tutorial is available exclusively to Laravel Daily Premium members.
Already a member? Login here
Premium membership includes:
Comments & Discussion
Hey, interestingly, what would you do if it were necessary to create a link between products based on the characteristic?
property
id title
property_values
id property_id title
product_properties
product_id property_values_id
and how to expand it further to make linking between products?
I mean, how should I write an migration to get such a result.
Each property is a separate product, collected in one group according to its characteristics.
And I have a question, how organize migrations
I use this in my model:
protected $with ='client'];but I still get warning from debugbarabout N+1 query. It's asking me to add App\Models\User in the model whereas I already defined the relationship of client in the method:public function client(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); }What am I doing wrong here?
Maybe you need to have
return $this->belongsTo(Client::class, 'user_id');instead?Hard to say without debugging the full code and where N+1 comes from, exactly.
Thank you Povilas for your suggestion. Client is a user and has a user role "client". I will try to post relevant code soon.