jeudi 12 novembre 2020

Laravel with() not working within whereHas clousure

Suppose i have routineDetails that has one allocation and that allocation has one meeting. When i try to use this:

$date='2020-11-12';
     $route_details = $this->routineDetail
                ->whereHas('allocation', function ($q) use ($all_sub_ids, $date) {
                    $q->whereIn('subject_id', $all_sub_ids)
                        ->with(['liveMeeting' => function ($q) use ($date) {
                            $q->where('join_date', $date);    
                        }]);
                })->get();

This query not working well. When i print

     foreach ($route_details as $k => $detail) {


        dd($detail->allocation->liveMeeting);
    }

It returns first meeting with date another. I guess the where query ($q->where('join_date', $date); ) not hit! I want all routines that has allocation of selected subjects and that has meeting with the allocation. Is there any way to do so ? Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3eWBNH0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire