I find the solution error . SQLSTATE[42000]: Syntax error or access violation:


  • | 642 points

    Hi guys,

    This code fragment Homestead in the works , but it does not work Laragon.

    0_1459021340675_error.PNG

    Database manual gives an error occurs if you laravel :
    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'admin.permissions' doesn't exist (SQL: select * from permissions)

    <?php

    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;

    class CreateRolePermissions extends Migration
    {
    /**
    * Run the migrations.
    *
    * @return void
    */
    public function up()
    {
    Schema::create('roles', function(Blueprint $table){
    $table->increments('id');
    $table->string('name');
    $table->string('label');
    $table->timestamps();

        });
    
        Schema::create('permissions', function(Blueprint $table){
            $table->increments('id');
            $table->string('name');
            $table->string('label');
            $table->timestamps();
    
        });
    
        Schema::create('permission_role', function(Blueprint $table){
            $table->integer('role_id')->unsigined();
            $table->integer('permission_id')->unsigined();
            
            $table->foreign('role_id')
                ->referance('id')
                ->on('roles')
                ->onDelete('cascade');
    
            $table->foreign('permission_id')
                ->referance('id')
                ->on('permissions')
                ->onDelete('cascade');
    
            $table->primary(['role_id', 'permission_id']);
    
        });
    
        Schema::create('role_user', function(Blueprint $table){
            $table->integer('role_id')->unsigined();
            $table->integer('user_id')->unsigined();
            
            $table->foreign('role_id')
                ->referance('id')
                ->on('roles')
                ->onDelete('cascade');
    
            $table->foreign('user_id')
                ->referance('id')
                ->on('users')
                ->onDelete('cascade');
    
            $table->primary(['role_id', 'user_id']);
    
        });
    
    }
    
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \DB::statement('SET FOREIGN_KEY_CHECKS = 0');
    
        Schema::drop('roles');
        Schema::drop('permissions');
        Schema::drop('permission_role');
        Schema::drop('role_user');
    
        \DB::statement('SET FOREIGN_KEY_CHECKS = 1');
    
    }
    

    }


  • administrators
    | 62136 points

    You may check your MySQL username & password in .env
    By default, Laragon use root and NO password.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.