Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dump within map function in Laravel

Within a map function i would like to use dd(); dump but i only get the first object.
When i use print_r(); within a map function i get all objects

$valeurCategorieCible = $CategoriesItineraires->map(function ($item) {
            return $item->ciblesParCategorie->map(function ($ciblesParCategorie) {
                return $ciblesParCategorie->cibles->map(function ($items) {
                    print_r($items); // Return all objects
                    dd($items); // Return only the first object then stop !
                });
            });
        });

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

According to the documentation for dd() it "dumps the given variables and ends execution of the script" – the important part is "ends execution of the script"!

If you don’t want to end execution use dump() instead of dd()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading