Have the next code working properly:
$system_breeds = SystemsGroup::find($group_id)->breeds;
$breeds = Breed::select('id', 'breed')->orderBy('breed')->get()->transform(function ($breed) use ($system_breeds) {
if ($system_breeds->contains($breed)) {
$breed->active = true;
}
return $breed;
});
On every breed that exists on the system_breeds I'm adding an active property as true.
What I want to do now, is something like this:
$system_breeds = SystemsGroup::where('id',$group_id)->with(['breeds' => function($q) use ($section_id){
$q->where('group_section_id', $section_id);
}])->get();
So, add a where filter on the relationship. But the "contains" doesn't work.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire