Eloquent: Calling Where on a relation

前端 未结 1 1019
你的背包
你的背包 2021-01-26 04:10

I have the following Eloquent ORM query.

$products2 = Product::with(\'metal\', \'metal.fixes\', \'metal.fixes.currency\')
    ->where(\'metal_id\', \'=\', 1)
         


        
1条回答
  •  离开以前
    2021-01-26 04:34

    You are looking for "Eager Load Constraints": http://laravel.com/docs/eloquent#querying-relations

     function($query){
        $query->where('currency_id', '=', 1);
    }))
    ->where('metal_id', '=', 1)
    ->get()->toArray();
    

    0 讨论(0)
提交回复
热议问题