I'm trying to seed a MySql table using Laravel seeder class. The problem is that it is not assigning the id
field (which is an incremental) value as I set. In the seeder class I got:
public function run()
{
Patropi\Entidade::create([
'id' => '0',
'nome' => 'entidade 0',
'cpfcnpj' => '12345678901'
]);
Patropi\Fornecedor::create([
'id' => '0',
'prioridade' => '0'
]);
}
On the database, the Fornecedor
table id is a foreign key which references the Entidade
id, that's why I want to have the same Id on both. The problem is, when it inserts on Entidade
it doesn't put it as id = 0 but instead it gives the value of the last incremental + 1. How to force laravel to insert 0 there instead? Thanks in advance.