Skip to content

Commit

Permalink
Add support for callables in model factories attributes (#20692)
Browse files Browse the repository at this point in the history
This will allow to use callables like [$factory, 'create'], Factory::create
or classes implementing the __invoke magic method.
  • Loading branch information
roberto-aguilar authored and taylorotwell committed Aug 23, 2017
1 parent 8061d9b commit 91765f5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Illuminate/Database/Eloquent/FactoryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Database\Eloquent;

use Closure;
use Faker\Generator as Faker;
use InvalidArgumentException;
use Illuminate\Support\Traits\Macroable;
Expand Down Expand Up @@ -265,7 +264,7 @@ protected function applyStates(array $definition, array $attributes = [])
protected function expandAttributes(array $attributes)
{
foreach ($attributes as &$attribute) {
if ($attribute instanceof Closure) {
if (is_callable($attribute)) {
$attribute = $attribute($attributes);
}

Expand Down

0 comments on commit 91765f5

Please sign in to comment.