Мне нужно получить все поставки клиента, поэтому с помощью Отношение Laravel, что я делаю:
Код: Выделить всё
$customers = Customer::with('consignments')->where('id','>',1)->get();
//and now I can access all consignments
foreach($customers as $customer ){
$customer->consignments
}
Код: Выделить всё
$customer_ids = Customer::selct('id')->where('id','>',1)->pluck('id')->toArray();
$consignments = Consignment::whereIn('customer_id',$customer_ids)->get()
Подробнее здесь: https://stackoverflow.com/questions/739 ... in-laravel
Мобильная версия