pickab00
4 months ago

withCount() returns 0

Posted 4 months ago by pickab00

Here is the code

    $array = $reservation->withCount('guestpaxes')->get();

    //This bit counts the total amount of pax in the query inclusive of guest
    $pax_count = '';

    foreach($array as $count){
        $pax_count = $count->guestpaxes_count;
    }

return $pax_count;

This returns 0 and I am not sure why. I looked at the docs and I am unsure where I went wrong

Please sign in or create an account to participate in this conversation.