I'm using a yaml file with a repeater field to select some categories on backend.
Then on partial i use:
$categories = \...\..\Category::whereIn('id', $categories)->get();
$this['categories'] = $categories;
Then on fronted i use:
{% for category in categories%}
{{ category.name }}
{% endfor %}
Everything is working fine and i get all categories of array variable $categories in frontend. The problem is than no matter if i change the array order the result order is always the same. For example this array:
$categories = [1, 2, 3, 4, 5];
gives the same order results with this array:
$categories = [4, 1, 2, 5, 3];
Is there a way to make it respect array order?
if you are using mysql its easy to customise order based on what order you are passing your id.
Client side
if any doubts please comment