Closed stuartcusackie closed 10 months ago
I've closed this issue because we don't consider it to be a bug. You shouldn't add a view composer to all views, that's going to break things, even for first-party Laravel packages.
You could check if it's a CP request though.
View::composer('*', function ($view) {
if (Statamic::isCpRoute()) {
return; // Do nothing in the CP.
}
$view->with('...');
});
Bug description
Getting this error when opening the entry editor on the control panel:
Method Illuminate\Support\Collection::title does not exist. (View: ...\vendor\statamic\cms\resources\views\entries\edit.blade.php)
I was messing with View Composers and this seems to break it, while all other pages are fine: App\Providers\AppServiceProvider.php
I can fix it by removing the wildcard:
View::composer(['partials.*', 'components.*'], function ($view) {
Not sure if I caused the problem elsewhere but perhaps someone can reproduce it. I would have thought the wildcard wouldn't include Statamic routes but I've no idea how that works.
How to reproduce
Use a wildcard on Laravel's view composer method.
Logs
No response
Versions
Statamic 3.3.10 Solo Laravel 9.11.0 PHP 8.0.10 spatie/statamic-responsive-images 2.11.2
Installation
Existing Laravel app
Antlers Parser
No response
Additional details
No response