Optimized (sub-)booking methods and index view for eager loading.

This commit is contained in:
Lukas Halbritter
2018-09-30 21:38:25 +02:00
parent 07ec0482a0
commit 3f6fe26ff0
4 changed files with 155 additions and 128 deletions
+3 -2
View File
@@ -16,9 +16,10 @@ class BookingsController extends Controller
*/
public function index($year)
{
$bookings = Booking::whereYear('date', '=', $year)
$bookings = Booking::with('subBookings.accountType.accountClass.ioType',
'subBookings.project')
->whereYear('date', '=', $year)
->orderBy('date')
->withCount('subBookings')
->get()
->groupBy(function($item) {
return Carbon::parse($item->date)->format('n');