Reputation: 4287
I am trying to create a View Composer in PHP Laravel 5. I have organized my template layouts like this
resources/
views/
layouts/
master2.blade.php
index.blade.php
master1.blade.php
I have already successfully register a composer for master1 by calling
view()->composer('master1', function ($view) { });
but, how to create one for master2 ?
I have tried both:
view()->composer('layouts.master1', function ($view) { });
view()->composer('layouts/master1', function ($view) { });
but none of them work.
Upvotes: 1
Views: 850
Reputation: 4287
I figure it out. The following syntax works:
view()->composer('layouts.master1', function ($view) { });
but first I have to clear the artisan cache and make a edit in view (like insert a space):
php artisan clear-compiled
php artisan cache:clear
Upvotes: 1