This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

37
vendor/laravel/framework/src/Illuminate/Database/Seeder.php vendored Normal file → Executable file
View File

@@ -24,13 +24,14 @@ abstract class Seeder
protected $command;
/**
* Seed the given connection from the given path.
* Run the given seeder class.
*
* @param array|string $class
* @param bool $silent
* @param array $parameters
* @return $this
*/
public function call($class, $silent = false)
public function call($class, $silent = false, array $parameters = [])
{
$classes = Arr::wrap($class);
@@ -45,12 +46,12 @@ abstract class Seeder
$startTime = microtime(true);
$seeder->__invoke();
$seeder->__invoke($parameters);
$runTime = round(microtime(true) - $startTime, 2);
$runTime = number_format((microtime(true) - $startTime) * 1000, 2);
if ($silent === false && isset($this->command)) {
$this->command->getOutput()->writeln("<info>Seeded:</info> {$name} ({$runTime} seconds)");
$this->command->getOutput()->writeln("<info>Seeded:</info> {$name} ({$runTime}ms)");
}
}
@@ -58,14 +59,27 @@ abstract class Seeder
}
/**
* Silently seed the given connection from the given path.
* Run the given seeder class.
*
* @param array|string $class
* @param array $parameters
* @return void
*/
public function callSilent($class)
public function callWith($class, array $parameters = [])
{
$this->call($class, true);
$this->call($class, false, $parameters);
}
/**
* Silently run the given seeder class.
*
* @param array|string $class
* @param array $parameters
* @return void
*/
public function callSilent($class, array $parameters = [])
{
$this->call($class, true, $parameters);
}
/**
@@ -120,18 +134,19 @@ abstract class Seeder
/**
* Run the database seeds.
*
* @param array $parameters
* @return mixed
*
* @throws \InvalidArgumentException
*/
public function __invoke()
public function __invoke(array $parameters = [])
{
if (! method_exists($this, 'run')) {
throw new InvalidArgumentException('Method [run] missing from '.get_class($this));
}
return isset($this->container)
? $this->container->call([$this, 'run'])
: $this->run();
? $this->container->call([$this, 'run'], $parameters)
: $this->run(...$parameters);
}
}