Laravel where on relationship object

前端 未结 6 792
余生分开走
余生分开走 2020-12-12 20:21

I\'m developing a web API with Laravel 5.0 but I\'m not sure about a specific query I\'m trying to build.

My classes are as follows:

class Event exte         


        
6条回答
  •  青春惊慌失措
    2020-12-12 20:58

    With multiple joins, use something like this code:

    $someId = 44;
    Event::with(["owner", "participants" => function($q) use($someId){
        $q->where('participants.IdUser', '=', 1);
        //$q->where('some other field', $someId);
    }])
    

提交回复
热议问题