Skip to content

Commit

Permalink
fix broken feature
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 14, 2020
1 parent ea4796e commit 9e4a866
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions src/Illuminate/Database/Seeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +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 mixed ...$parameters
* @param array $parameters
* @return $this
*/
public function call($class, $silent = false, ...$parameters)
public function call($class, $silent = false, array $parameters = [])
{
$classes = Arr::wrap($class);

Expand All @@ -46,7 +46,7 @@ public function call($class, $silent = false, ...$parameters)

$startTime = microtime(true);

$seeder->__invoke(...$parameters);
$seeder->__invoke($parameters);

$runTime = number_format((microtime(true) - $startTime) * 1000, 2);

Expand All @@ -59,15 +59,27 @@ public function call($class, $silent = false, ...$parameters)
}

/**
* Silently seed the given connection from the given path.
* Run the given seeder class.
*
* @param array|string $class
* @param mixed ...$parameters
* @param array $parameters
* @return void
*/
public function callSilent($class, ...$parameters)
public function callWith($class, array $parameters = [])
{
$this->call($class, true, ...$parameters);
$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);
}

/**
Expand Down Expand Up @@ -122,12 +134,12 @@ public function setCommand(Command $command)
/**
* Run the database seeds.
*
* @param mixed ...$parameters
* @param array $parameters
* @return mixed
*
* @throws \InvalidArgumentException
*/
public function __invoke(...$parameters)
public function __invoke(array $parameters = [])
{
if (! method_exists($this, 'run')) {
throw new InvalidArgumentException('Method [run] missing from '.get_class($this));
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseSeederTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testSendParamsOnCallMethodWithDeps()
$seeder = new TestDepsSeeder;
$seeder->setContainer($container);

$seeder->__invoke('test1', 'test2');
$seeder->__invoke(['test1', 'test2']);

$container->shouldHaveReceived('call')->once()->with([$seeder, 'run'], ['test1', 'test2']);
}
Expand Down

0 comments on commit 9e4a866

Please sign in to comment.