We're trying to use multiple view composers along with this package to help clean up our controllers. The problem is that we can't figure out how to conditionally load only the view composer we want when some of our view names are exactly the same.
Here's a couple different homepages for platforms that each need very different data:
/resources/themes/platform-one-theme/pages/index.blade.php
/resources/themes/platform-two-theme/pages/index.blade.php
The view name for each of those homepages is 'pages.index'
So in our ComposerServiceProvider.php, we have:
View::composer(['pages.index'], 'App\Http\ViewComposers\Platform-One-ViewComposer');
View::composer(['pages.index'], 'App\Http\ViewComposers\Platform-Two-ViewComposer');
...and our problem is that both of those will both be loaded. How can we conditionally apply only the view composer for our theme? It looks like we don't have access to request within ComposerServiceProvider, and it doesn't seem to work with middleware.
We're trying to use multiple view composers along with this package to help clean up our controllers. The problem is that we can't figure out how to conditionally load only the view composer we want when some of our view names are exactly the same.
Here's a couple different homepages for platforms that each need very different data:
/resources/themes/platform-one-theme/pages/index.blade.php
/resources/themes/platform-two-theme/pages/index.blade.php
The view name for each of those homepages is 'pages.index'
So in our ComposerServiceProvider.php, we have:
...and our problem is that both of those will both be loaded. How can we conditionally apply only the view composer for our theme? It looks like we don't have access to request within ComposerServiceProvider, and it doesn't seem to work with middleware.