dimanche 26 mai 2019

Change the Value of an existing Laravel Collection key

I have a Laravel Collection $page in which I am trying to update some values based on a value in another collection. But instead up updating a new element is being added to $page.

enter image description here

    if($page->get('Lang') !== null ){
        $l = $page->get('Lang');

        foreach ($l as $thisLang => $value) {
            if($lang == $thisLang){
               //  this is where I am attempt is overwrite the variable
                $page->Name = $value->Name;

                break;
            }
        }
    }

Being fairly new to Laravel I am not sure what I am doing wrong. Any code corrections are appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2VOCgQd
via IFTTT

Aucun commentaire:

Enregistrer un commentaire