Я пытаюсь показать данные из нескольких таблиц.Это работает, когда я использую конструктор запросов.Но как сделать это по-красноречивее?
Таблица квитанций = 'receive_id', 'notes', 'plate' и т. Д.
Table cars ='plate', 'car_name', 'brand_id,' cst_id 'и т. д.
Таблица брендов =' brand_id, 'brand_name' и т. д.
Таблица customer = 'cst_id', 'cst_name' и т. Д.
Мой контроллер:
$history = DB::table('receipt')
->join('cars', 'receipt.plate', '=', 'cars.plate')
->join('brands', 'cars.brand_id', '=', 'brand.brand_id')
->join('customers', 'cars.cst_id', '=', 'customers.cst_id')
->where('customers.cst_id', auth()->user()->id)
->get();
return view('frontend.customer', compact('history'));
Блейд учетной записи моего клиента:
@foreach($history as $his)
<li> {{ $his->receipt_id }} </li>
<li> {{ $his->plate }} </li>
<li> {{ $his->car_name }} </li>
@endforeach