In the Blade templating engine, how to use "if" to determine null or empty?
{{{ Auth::user()->age }}}
How check variable is NULL or not in laravel? The is_null() function checks whether a variable is NULL or not. This function returns true (1) if the variable is NULL, otherwise it returns false/nothing.
You can check if the column value of a record is null or not in laravel using whereNotNull() and exists() method. exists() method returns false if the column value of a record in the table is null and it returns true if column value is not null.
The __ helper function can be used to retrieve lines of text from language files. You can retrieve lines of text from either key-based translation files (represented as PHP arrays) or from literal, string-based translation files (represented as a JSON object). Replacements are passed as a key/value pair.
You can do it as bellow
@if (empty(Auth::user()->age))
// your if code
@else
// your else code
@endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With