use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMenusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('menu', function (Blueprint $table) {
$table->increments('id');
$table->string('opcao');
$table->string('href');
$table->boolean('session');
$table->timestamps();
});
Schema::create('submenu', function (Blueprint $table) {
$table->increments('id');
$table->integer('submenu_id')->index;
$table->foreign('submenu_id')->references('id')->on('menu');
$table->string('opcao');
$table->string('href');
$table->boolean('ligado');
$table->timestamps();
});
}}
is giving malformed foreign key constraint error.
Someone can help me. This error occurs when I run the command php artisan migrate
.