Laravel 5 Migrate Base table or view not found: 1146

I am in a big problem. I try to run php artisan migrateto create a migration table, but I get

[2016-03-08 05:49:01] local.ERROR: exception "PDOException" with the message "SQLSTATE [42S02]: no base table or view found: 1146 Table" testing.permissions "does not exist" in D: \ XAMPP \ HTDOCS \ LMS testing \ provider \ Laravel \ framework \ SRC \ Light \ Database \ connection.php: 333

error. I tried and search the Internet where I made a mistake, but I did not find any solution.

I also tried the Base table or view not found: 1146 Laravel 5 table and Running the Laravel tutorial, getting the “Base table or view not found: 1146 Table 'sdbd_todo.migrations' does not exist” , but I did not succeed.

I also tried to start php artisan list, but again I get the same error. I do not know why. Please offer me a solution.

updated

**RolesPermission migration table**

Schema::create('roles', function(Blueprint $table){
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('label');
            $table->string('description')->nullable();
            $table->timestamps();            
        });

        Schema::create('permissions', function(Blueprint $table){
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('label');
            $table->string('description')->nullable();
            $table->timestamps();            
        });

        Schema::create('permission_role', function(Blueprint $table){
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('permission_id')
                    ->references('id')
                    ->on('permissions')
                    ->onDelete('cascade');

            $table->foreign('role_id')
                    ->references('id')
                    ->on('roles')
                    ->onDelete('cascade');

            $table->primary(['permission_id', 'role_id']);
        });

        Schema::create('role_user', function(Blueprint $table){
            $table->integer('role_id')->unsigned();
            $table->integer('user_id')->unsigned();

            $table->foreign('role_id')
                    ->references('id')
                    ->on('roles')
                    ->onDelete('cascade');

            $table->foreign('user_id')
                    ->references('id')
                    ->on('users')
                    ->onDelete('cascade');

            $table->primary(['role_id', 'user_id']);

        });


.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=W8YWZe3LCngvZzexH3WLWqCDlYRSufuy

DB_HOST=127.0.0.1
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
+8
source share
10 answers

Check the migration file, maybe you are using Schema :: table, for example:

Schema::table('table_name', function ($table)  {
    // ...
});

If you want to create a new table, you should use Schema :: create:

Schema::create('table_name', function ($table)  {
    // ...
});

Laracast .

+6

, , , .

1)

2) 9999_99_99_999999_create_foreign_keys.php

3) . 999..9.php , , .

4) , . .

+2

:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.permissions' doesn't exist

, permissions . :

Schema::create('permission_role', function(Blueprint $table){
        $table->integer('permission_id')->unsigned();
        $table->integer('role_id')->unsigned();

        $table->foreign('permission_id')
                ->references('id')
                ->on('permissions')
                ->onDelete('cascade');

        $table->foreign('role_id')
                ->references('id')
                ->on('roles')
                ->onDelete('cascade');

        $table->primary(['permission_id', 'role_id']);
    });

Schema , permissions.

, Laravel , , , .

, , . , migrations:

2016_10_09_134416_create_permission_role_table 
2016_10_09_134416_create_permissions_table 

. , permission_role permissions, , :

2016_10_09_134415_create_permissions_table 
2016_10_09_134416_create_permission_role_table 

create_permissions_table, create_permissions_role_table. :

composer dump-autoload

, .

+1

, . AuthServiceProvider, . , .

+1

, . :

fooobar.com/questions/14626369/...

    try {

        return Permission::with('role')->get();

    } catch (\Exception $e) {

        return [];

    }
+1

.

, . , , .

//Problematic code
Route::view('users', 'users', [ 'users' => User::all() ]);

Route::get('/users', function () {
    return view('users', ['users' => User::all()]);
});

. , , .

+1

, , , , , . , auth middleware. , config/app.php. , auth middleware

0

, - , , , , , , db, .

,

protected $commands = []

app\Console\Kernel.php.

!!!!: -)

0

, , PermissionsServiceProvider config/app.php .

0

.

, , boot AppServiceProvider ( Model, ).

0

All Articles