
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
- Use of undefined constant laravel
- How to check data inserted or deleted in pivot after toggle method
- Touch parent updated_at in Laravel
- Display first n record from collection in laravel view
- How to create projects method with belongstomany relationship in user model
- How to pass variable from controller to model in Laravel
- How to use bootstrap pagination in laravel 8
- JQuery each loop on json response after ajax in laravel
- Update if exist else insert new record in laravel
- How to get route name on visit URL in laravel
- Update email with unique validation in laravel
- Remove public from url in laravel project
- How to get user information using hootlex/laravel-friendships package in laravel
- How to change default timestamp fields name in Laravel
- Laravel API response format
- How to get only time from created_at in laravel
- How to upload files to amazon s3 bucket using Laravel
- Laravel specific table Migration
- Submit form without CSRF token in Laravel
- Create project table with model and migration
- Get current URL on visit URL in Laravel
- Undefined property: stdClass::$title
- Get only 10 records from table in laravel
- How to create new user without form submission in laravel
- How to automatically update the timestamp of parent model in Laravel