
How to check column value of a record is null or not in laravel
How to check column value of a record is null or not in laravel
In this tutorial, we will try to find the solution to "How to check column value of a record is null or not in laravel" through programming.
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.-
Laravel whereNotNull() with exists() method to check if the column value is null or not
$hasImage = User::where('id', Auth::user()->id)->whereNotNull('image')->exists(); dd($hasImage);
Output :
true
or
false
It returns true if record does not have null value in column and return false if record have null value in column.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Class 'App\Providers\Auth' not found
- There are no commands defined in the "route:" namespace
- Where to use whereNotNull eloquent in laravel
- How to Access Array in blade laravel
- How to insert value to additional columns in pivot table in laravel
- Skip first n record and display rest records in laravel view
- How to insert multiple rows in mysql using loop in laravel?
- Class 'App\Rules\Hash' not found in Laravel
- How to display order by null last in laravel
- How to use more than one query scope in Laravel
- Laravel order by date not working
- How to pass data to multiple partial view files in laravel
- FirstOrCreate() Not Inserting Model
- How to call Laravel route in jQuery
- If no route matched route::fallback in laravel
- Permission denied error while creating storage link in Laravel
- Update record after find method in lavavel
- First and last item of the array using foreach iteration in laravel blade
- How to get id of next record in laravel
- How to insert dynamic value to additional column in pivot table in laravel
- How to get CSRF token in laravel controller
- How to display 1 day ago in comments in laravel view
- How to get specific columns using with method in laravel Eloquent relationship
- Laravel csrf token mismatch for ajax POST Request
- Get last record from table in laravel