maybe you don't have records that match your query
try dd() for each query separate
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello!
I have a difficult time building the query for the table.
There is what I need to do:
dd(Bookings::where('status', '!=', 'in-progress')->where('game_id', 2)->where('method', 'online')->count());
I need to split that query for a few pieces.
$totalBookings = Bookings::query()->where('status', '!=', 'in-progress');
...
$totalBookings = $totalBookings->where('game_id', 2)->where('method', 'online');
...
$summaryGame = new \stdClass();
$summaryGame->all = $totalBookings->count();
$summaryGame->checked = $totalBookings->where('status', 'checked-in')->count();
$summaryGame->notShown = $totalBookings->where('status', 'not-shown')->count();
$summary->push($summaryGame);
But I have the result only for $summaryGame->all, everything else gives me 0.
Could you, please, help me, if I misunderstood the concept of the query building? Thanks!
@ya-ya-it
Try now
$bookings = Bookings::where('status', '!=', 'in-progress')->where('game_id', 2)->where('method', 'online')->get();
$totalBookings= $totalNotShown = $totalCheckedIn = 0;
foreach($bookings as $booking) {
if($status == 'checked-in')
$totalCheckedIn++;
elseif($status == 'not-shown')
$totalNotShown++;
else
$totalBookings++;
}
$summaryGame = new \stdClass();
$summaryGame->all = $totalBookings;
$summaryGame->checked = $totalCheckedIn;
$summaryGame->notShown = $totalNotShown;
$summary->push($summaryGame);
Please or to participate in this conversation.