Answer the question
In order to leave comments, you need to log in
How to make a connection?
Lot table: id, brand_id, model_id
Brand table: id, name
Models table: id, model_id, brand_id, name
public function brand() {
return $this->belongsTo(Brand::class, 'brand_id');
}
public function models() {
return $this->hasMany(Models::class, 'brand_id', 'brand_id');
}
{{$lot->brand->name}} //отображается название бренда
{{$lot->models}}
Answer the question
In order to leave comments, you need to log in
So why are you linking the lot with models through the brand?
model_id is in any case unique for the brand and associated with the brand
. What kind of nonsense is the model_id field in models? They already have their own ID, so connect with it.
Those. write models.id to the lot, but not models.model_id. Some kind of porridge
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question