haizone
1 year ago

count Collections after groupby

Posted 1 year ago by haizone

i make a groupby() in a Collections and i get that:

this is my code:

$field->specValues()->get()->groupby('value')

and i get that result:

Collection {#1385 ▼
  #items: array:45 [▼
   "Nokia" => Collection {#813 ▼
     #items: array:5 [▶]
   }
   "HTC" => Collection {#893 ▼
     #items: array:22 [▶]
   }
  "Elephone" => Collection {#892 ▼
    #items: array:4 [▶]
   }
   "Doogee" => Collection {#895 ▶}
  "ThL" => Collection {#898 ▶}

and i whant to add a sory by the count on the Collection inside the value here:

in

Nokia => 5 array
Elephone=> 4
HTC => 22 array

and i whant to sory in one code ($field->specValues()->get()->groupby('value')) need to continu to sort that by the Collection thay hve in the value

this need to be the result:

HTC => 22 array
Nokia => 5 array
Elephone=> 4

thanks

Please sign in or create an account to participate in this conversation.