Answer the question
In order to leave comments, you need to log in
How best to structure the links of the three models (a la price)?
I continue to rewrite the old project on laravel. In an attempt to optimize everything complicated by tradition.
There are 3 models. city, category, service. Roughly speaking price list.
City-Category everything is clear here. Many to Many via add. table. And then the shutdown begins.
category service. made One to Many. It seems logical - each service belongs to some category. In this case, the category is tied to the city.
And now there is a situation that in different cities the cost of the same service may be different.
And I can not figure out in any way what to tie where in this case.
Tried to do
public function services()
{
return $this->hasManyThrough(
Service::class,
Category::class,
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question