I've created a few custom seeders and now i'm trying to get them to seed from DatabaseSeeder.php
but it will only do one at a time
<?php
use Database\seeds\CandySeeder;
use Database\seeds\ChocolateSeeder;
use Database\seeds\AlmondSeeder;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call ('FirewallModelsSeeder');
}
}
public function run()
{
Model::unguard();
$this->call ('CandySeeder', 'ChocolateSeeder', 'AlmondSeeder');
}
and
public function run()
{
Model::unguard();
$this->call arrary ('CandySeeder', 'ChocolateSeeder', 'AlmondSeeder');
}
Only CandySeeder runs =/ - I have to move the one i want to be ran to the first in line. Is there a way to pass a list so they can all run. I tried having 1 line for each, but db:seed gave me an error that it couldn't redeclare seeder
public function run()
{
Model::unguard();
$seeders = array ('CandySeeder', 'ChocolateSeeder', 'AlmondSeeder');
foreach ($seeders as $seeder)
{
$this->call($seeder);
}
}
simply run the call function inside a loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With