lundi 5 décembre 2016

Problems with seeds in Laravel

My problem is the next one:

I have already done some seeds, and im trying to get the primary key to the another table/seed.

Here is the code i have problems:

$factory->define(App\Movimento::class,function(Faker\Generator $faker){

$Transportador=App\Transportador::pluck('TransportadorId');

$array =[

'MovimentoId'   => $faker->randomNumber,

'Data'          => $faker->date,

'Destino'       => $faker->word,

'EMExp'         => $faker->word,

'Transp'        => $faker->randomNumber($Transportador)

];

return $array;

});

So the "Transp" is a Foreign Key and i want the same key has the "TransportadorId" from the other seed.

Here is the code how is clear from errors:

$factory->define(App\Transportador::class,function(Faker\Generator $faker){

$nbDigits='3';

$redDigits='9';

$array =[

'TransportadorId'    => $faker->randomNumber($nbDigits),

'Nome'               => $faker->text,

'Contribuinte'       => $faker->randomNumber($redDigits)

];

return $array;

});

P.S-> I'm sorry for my bad English.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gY3WBU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire