How to use where with relationships.
Created 6 years ago by gonziisHey, Im trying to fetch all data in my controller for my model which has multiple relationships
public function index(LeemumiRepositoryInterface $leemumi)
{
return $this->view->make("xxxxx::leemumi/index");
}
dd($leemumi)
returns
LeemumiRepository {#2125 ▼
#model: LeemumiModel {#2126 ▼
#searchable: true
#table: "leemumi_leemumi"
#titleName: "name"
#rules: array:21 [▶]
#fields: array:21 [▶]
#dates: array:4 [▶]
#relationships: array:7 [▼
0 => "file"
1 => "files"
2 => "lemumu_categories"
3 => "lietu_classification"
4 => "likumu_article"
5 => "nannce"
6 => "adressat"
]
As you can see the relationship with nannce
is there, but how to write code to get specific Leemumi
that has nannce
with specific ids? I imagine it would be something like $leemumi->where("nannce.id","=",10)
for example
Please help, Im really struggling with this, some hint at least would be nice.
Relationship fields always add a Laravel relationship method to the model. So the PHP API would look like this for example:
Twig would be the same way: