php - Laravel 8: Check if Record in Database is Empty
one text
Solution:
Try with whereNull() and count() for conditional
$businessDashboardUserId = BusinessDashboard::whereNull('user_id')->first();
if (!$businessDashboardUserId->count()) {
dd('Is Null');
} else {
dd('Not Null');
}
Or even nicer
if (!BusinessDashboard::whereNull('user_id')->exists()) {
dd('Is Null');
} else {
dd('Not Null');
}
Source