Certainly! You can achieve the desired indexed array by using the pluck method with the keyBy method. Here's how you can modify your code:
$sa = App\Models\SeatAllocation::where('seat_id', '<', 65800)
->groupBy('seat_id')
->selectRaw('count(*) as total, seat_id')
->get()
->pluck('total', 'seat_id')
->toArray();
The pluck method retrieves all of the values for a given key (in this case, 'total'), and the second argument to pluck specifies the key for the resulting array (in this case, 'seat_id'). The toArray method then converts the collection to a plain PHP array.
The resulting $sa array will have the seat_id as the key and the total as the value, just as you wanted:
[
65798 => 6,
65799 => 6
]