Laravel You requested 1 items, but there are only 0 items available
Use inRandomOrder()
instead:
$physician = SelectOption::where('select_option_group_id', 1)->inRandomOrder()->first();
$name = is_null($physician) ? 'No data available' : $physician->name;
Check if collection is not empty prior doing random()
:
$collection = SelectOption::where('select_option_group_id', 1)->pluck('name');
if (!$collection->isEmpty()) {
$physician = $collection->random();
} else {
...
}