Tuesday, November 1, 2016

is_null and empty in laravel 5.3

So I have an empty table here :
Let's see the first output of this code :
So if we use ::find(), then variabel will pass both empty and null checker....Next how about this one :
Result :
Naaah... as we can see, if we use ::select then variabel is not empty or null... :v
buuut... let's see what happens if we check $empty->name,
Result :
We can't use $empty->name for is_null, so :
Sooo... if we just check $empty, then it won't be empty, but if we use $empty->name, it will be an empty .... yaaapss... Next code :
Again, we can't use $empty->name, so just comment it on.....aaaand... the output is like this :
So if we use ->first(), it will be an empty and null... but how about ->get();
So ->get() will fail at is_null... :D.. Then it will be safe if we use empty($var) instead of using is_null.... Ok... the last :
Like we got from get() before, is_null can't be applied, but if we change it to use ->first(), then :












No comments:

Post a Comment