Laravel You requested 1 items, but there are only 0 items available
PHP Snippet 1:
$collection = SelectOption::where('select_option_group_id', 1)->pluck('name');
if (!$collection->isEmpty()) {
$physician = $collection->random();
} else {
...
}
PHP Snippet 2:
$physician = SelectOption::where('select_option_group_id', 1)->inRandomOrder()->first();
$name = is_null($physician) ? 'No data available' : $physician->name;