1
I’m learning now how to use the Migration
of Laravel
. I managed to understand well the functioning, but 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 key Foreign in the field nivel_id
which refers to niveis.id
.
How can I do that in Laravel
?