1
I’m having a problem using onDelete('set null') in a foreign key. You are returning the error: 
[Illuminate Database Queryexception]
SQLSTATE[HY000]: General error: 1215 Cannot add Foreign key Constraint (SQL: alter tableusersadd Constraintusers_instituicoes_id_foreignForeign key (instituicoes_id) Referencesinstituicoes(id) on delete set null)[Pdoexception]
SQLSTATE[HY000]: General error: 1215 Cannot add Foreign key Constraint
If I change the set null for cascade works.
I’m creating Migration like this:
       Schema::create('users', function (Blueprint $table) {
                $table->increments('id');
                $table->string('nome');
                $table->string('user')->unique();
                $table->string('email')->unique();
                $table->string('password');
                $table->integer('instituicoes_id')->unsigned();
                $table->string('telefone')->nullable();
                $table->string('img')->default('default.png');
                $table->boolean('ativo');
                $table->rememberToken();
                $table->timestamps();
            });
            Schema::table('users', function(Blueprint $table){
                $table->foreign('instituicoes_id')
                      ->references('id')
                      ->on('instituicoes')
                      ->onDelete('set null');
            });