5 months ago

Laravel view()->share error

Posted 5 months ago by zefex

I'm trying to share the categories so I can render in all pages but I'm getting an error when running: php artisan migrate

In my AppServiceProvider:

    public function boot()
        view()->share('shared', (object) [
            'categories' => Category::all(),

This way I can $shared->categories

The problem is that when I try to run the migrations I get an error:

Undefined table: 7 ERROR: relation "categories" does not exist

It looks like it's calling the boot from AppServiceProvider every time I call php artisan migrate

Please sign in or create an account to participate in this conversation.