WhereNotExists Laravel Eloquent

后端 未结 2 1640
灰色年华
灰色年华 2021-01-04 09:30

Little bit of trouble with the eloquent framework for laravel.

I need to replicate a query like this :

SELECT *
FROM RepairJob
WHERE NOT EXISTS (SE         


        
2条回答
  •  既然无缘
    2021-01-04 10:08

    Try doesntHave() method. Assuming 'dismissedRequests' as relation name in RepairJob model.

    $jobs = RepairJob::with('repairJobPhoto', 'city', 'vehicle')
        ->where('active', 'Y')->doesntHave('dismissedRequests')->get();
    

提交回复
热议问题