I'm now learning to use Migration
of Laravel
. I was able to understand the understanding well, but I still do not know how to add a foreign_key
I have the following Migration:
Schema::create('usuarios', function (Blueprint $bp)
{
$bp->increments('id');
$bp->unsignedInteger('nivel_id');
$bp->string('nome');
$bp->string('username');
$bp->string('password', 455);
});
I need to create a foreign key in the nivel_id
field that references niveis.id
.
How can I do this in Laravel
?