Specific order for checkbox list
I have this repeater with checkboxlist. I am adding amenities in a specific order, but the order is not keep after save. How can I solve it? For example I am checking 1 King Bed and then Ensuite Bathroom with shower, vanity and toilet. I need the 1 King Bed to be first in the list
2 Replies
Do you have a sort order for your room amenities in your database? If so you should be able to do
RoomAmenity::orderBy('sort_order_column')->all()->pluck('name', 'id)
If you don't have a sorting column you'll need to add one to get a custom sorting since otherwise you'll be limited to the columns on your table like id, name, etc.
All add it’s also the perfect opportunity to create a RoomAmenity resource and add reorderable()
to it so you can just drag and drop the order you need. But again, you’ll need a sort column.Thank you 😁