mercredi 2 décembre 2020

How to change the collection on the basis of array in column value

I want to change the laravel collection because I want to pass this collection to generate report. How to change collection on the basis of the value in the column.

Previous:

Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[id] => 23
[form_type] => radio
[details] => [{"id":55 title:"AA" name:"BB"}, {"id":56 title:"CC" name:"DD"}]
)
[1] => stdClass Object
(
[id] => 24
[form_type] => checkbox
[details] => [{"id":57 title:"PP" name:"QQ"}, {"id":58 title:"RR" name:"SS"}]
)
)
)

--details column has array of objects, I want it as below format:

Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[id] => 23
[form_type] => radio
[title] => "AA"
[name] =>  "BB"     
)
[1] => stdClass Object
(
[id] => 23
[form_type] => radio
[title] => "CC"
[name] =>  "DD"     
)        
[2] => stdClass Object
(
[id] => 24
[form_type] => checkbox
[title] => "PP"
[name] =>  "QQ"
)
[4] => stdClass Object
(
[id] => 24
[form_type] => checkbox
[title] => "RR"
[name] =>  "SS"
)
)
)


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire