1 year ago

Artisan commands all give Base table or view not found error

Posted 1 year ago by Snapey

I know why this is, I have a service provider that tries to read from a permissions table.

If the database is completely dropped, then the table does not exist and because it is in the boot method of a service provider then no artisan commands can run - including migrating the database to create the table in question.

I got around it like the below, by wrapping in a schema check, but it seems a bit clumsy. Anyone with a better solution?

        if(Schema::hasTable('permissions')) {

            Permission::get()->map(function ($permission) {
                Gate::define($permission->name, function ($user) use ($permission) {
                    return $user->hasPermissionTo($permission);

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