I want to make a query that involves a count, and it works. The query is this:
$user = Auth::user();
$id = $user->id;
$users = DB::table('cuentas as a')
->join('pasajeros as b', 'b.id', '=', 'a.pasajero_id')
->where('b.usuarios_id', $id)
->select(DB::raw('count(*) as user_count'))
->get();
return $users;
The return $ users brings me this:
[{"user_count": 0}]
And it's fine, I have 0, because there's still no record where the user's id is contained. But what I need to do is that the content of $ users is only the number, in that case, the 0. In order to use it in an if, otherwise, that $ users is not a number like that.