I have 3 tables, that are related with each other, and in my index page i wish to retrive all the products data, but in my case when i retrieve all the products is giving me with all the languages. I wish to retrieve all the products of a specific language based on language_id, but cant figure out what to change in my model, since the method ("translatedProducts") that i have in my model only works with single products calling.
DB:
Languages:
- id;
- name;
Products:
- id;
- online;
- price;
Products_Translations:
- id;
- product_id;
- name;
- description;
- language_id;
Model Product method:
public function translatedProducts(){
return $this->hasMany(ProductTranslation::class);
}
My current controller calling all products:
$products = Product::all();
via Pedro