dimanche 6 octobre 2019

Checking if column is null Laravel

I have this column my database:

enter image description here

As you can see the time_out is null, and when I use this query:

   $checkertimeout = Attendance::where('emp_id', $request->emp_id)
                    ->where('attend_date', $date)->get(['time_out']);

I get this output:

[{"time_out":null}]

But when I use it in an if-else statement:

        if ($checkertimeout->isEmpty()) {
            echo "works";
        } else {
            echo "wont work";
        }

it display won't work. Any help is appreciated, I'm new to Eloquent query :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire