Skip to content

Commit

Permalink
make model factory after method signatures more consistent (#23676)
Browse files Browse the repository at this point in the history
  • Loading branch information
unstoppablecarl authored and taylorotwell committed Mar 23, 2018
1 parent 5520954 commit 3fd1b23
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Illuminate/Database/Eloquent/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ public function state($class, $state, $attributes)
*
* @param string $class
* @param callable $callback
* @param string $name
* @return $this
*/
public function afterMaking($class, $callback)
public function afterMaking($class, callable $callback, $name = 'default')
{
$this->afterMaking[$class]['default'][] = $callback;
$this->afterMaking[$class][$name][] = $callback;

return $this;
}
Expand All @@ -133,23 +134,22 @@ public function afterMaking($class, $callback)
* @param callable $callback
* @return $this
*/
public function afterMakingState($class, $state, $callback)
public function afterMakingState($class, $state, callable $callback)
{
$this->afterMaking[$class][$state][] = $callback;

return $this;
return $this->afterMaking($class, $callback, $state);
}

/**
* Define a callback to run after creating a model.
*
* @param string $class
* @param callable $callback
* @param string $name
* @return $this
*/
public function afterCreating($class, $callback)
public function afterCreating($class, callable $callback, $name = 'default')
{
$this->afterCreating[$class]['default'][] = $callback;
$this->afterCreating[$class][$name][] = $callback;

return $this;
}
Expand All @@ -162,11 +162,9 @@ public function afterCreating($class, $callback)
* @param callable $callback
* @return $this
*/
public function afterCreatingState($class, $state, $callback)
public function afterCreatingState($class, $state, callable $callback)
{
$this->afterCreating[$class][$state][] = $callback;

return $this;
return $this->afterCreating($class, $callback, $state);
}

/**
Expand Down

0 comments on commit 3fd1b23

Please sign in to comment.