I have 2 models. One called Hotel and one called Amenities.
In model Hotel I have a multiple select field of amenities. When I change the order, it's saved in the database for example :
a:9:{
i:0;s:2:"30";
i:1;s:2:"31";
i:2;s:2:"33";
i:3;s:2:"27";
i:4;s:2:"35";
i:5;s:2:"40";
i:6;s:2:"34";
i:7;s:2:"42";
i:8;s:2:"43";
}
But when I use the deserialized attribute, the array is ordered by ID so It'll be :
Array => [
[0] => [27]
[1] => [30]
[2] => [31]
[3] => [33]
[4] => [34]
[5] => [35]
].....
How can I preserve the order after a deserialized attribute ?
Hello,
I have 2 models. One called Hotel and one called Amenities. In model Hotel I have a multiple select field of amenities. When I change the order, it's saved in the database for example :
a:9:{ i:0;s:2:"30"; i:1;s:2:"31"; i:2;s:2:"33"; i:3;s:2:"27"; i:4;s:2:"35"; i:5;s:2:"40"; i:6;s:2:"34"; i:7;s:2:"42"; i:8;s:2:"43"; } But when I use the deserialized attribute, the array is ordered by ID so It'll be : Array => [ [0] => [27] [1] => [30] [2] => [31] [3] => [33] [4] => [34] [5] => [35] ]..... How can I preserve the order after a deserialized attribute ?
Thank you for your help, Rebecca