My Laravel version is 5.8.23
According to the documentation on Laravel View Composer, in order to attach a view composer to multiple views at once, pass the views in an array inside the first argument like:
View::composer(['profile', 'dashboard'],
'App\Http\View\Composers\MyViewComposer');
When I try to use similar like that, my second value in the array does not get the values I passed in the AnimalComposer.php
My code:
View::composer(['animal.edit', ' animal.create'],
'App\Http\Views\Composers\AnimalComposer'
);
I get errorException in animal/create.blade.php
Undefined variable: animalType
But if I use multiple View::composer to send the data to the blade.php, it is working fine.
public function boot()
{
View::composer('animal.edit',
'App\Http\Views\Composers\AnimalComposer'
);
View::composer('animal.create',
'App\Http\Views\Composers\AnimalComposer'
);
}
Am I missing something? Do I need to use View::composer every time I send AnimalComposer to the view? Does Laravel now do not support multiple views inside array?
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2KzHqhW
via IFTTT
Aucun commentaire:
Enregistrer un commentaire