I have a table which screenshot is attached below
I want to show all the Account Type and but it should be shown in option group
How can I achieve this???
The Laravel helper function groupBy() will help you solve this problem. Data grouping example:
$cars = Car::where('status', 1)->get();
$carModels = $cars->groupBy('model');
Blade example:
<select name="car_id">
@foreach($carModels as $model => $cars)
<optgroup label="{{ $model }}">
@foreach($cars as $car)
<option value="{{ $car->id }}">{{ $car->name }}</option>
@endforeach
</optgroup>
@endforeach
</select>