samedi 18 février 2017

Pushing an item to an array from view share?

I have tried googleing with no avail so thought I'd ask here to see if anyone has achieved the following...

In a controller I have a simple array

$test = [1,2,3];

I am passing the said array to the view file like so:

return View('test')->withTest($test);

and in the view file I am looping through the array

 @foreach($test as $number) 
     
 @endforeach

This is just for the benefit of this post, anyway, is it possible to add a value to that array from a serviceprofider, to use in my foreach? I tried using view::share() but that doesn't append the value, for example

 View::share('test', [6,7,8]);

Won't append, but just create a new definition of the varible, so is it possible to append the nunbers 6,7,8?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lVkJIT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire