I'm working on my first Laravel project and wanting to generalize a bit the views I'll get over the next mistake I do not understand.
Create my composer class:
namespace App\Http\Composers;
use Illuminate\Contracts\View\View;
class TilesmenuComposer(){
public function compose(View $view){
$view->with('itemMenuList', user()->getMenu());
}
}
Then create a provider for this class:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class TilesmenuProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->composeTilesMenu();
}
public function composeTilesMenu(){
view()->composer('layouts.tilesmenu',
'App\Http\Composers\TilesmenuComposer');
}
}
and I registered the provider in config / app.php
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TilesmenuProvider::class,
But every time I call the controller, and insert the call
@include('layouts.tilesmenu')
Return the error:
Class App\Http\Composers\TilesmenuComposer does not exist (View: C:\BigData\Laravel\Tol\resources\views\home.blade.php)
I have read all the threads here and in other communities, but unfortunately I can not find the answer. Maybe you can give me a hand with this.
Greetings and thanks.