diff --git a/composer.json b/composer.json index 412920d..7a691ca 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "homepage": "https://github.com/jeffochoa/factory-stories", "license": "MIT", - "version": "1.0", + "version": "1.1", "authors": [ { "name": "Jeff Ochoa" @@ -18,5 +18,12 @@ "FactoryStories\\": "src/" } }, - "require": {} + "require": {}, + "extra": { + "laravel": { + "providers": [ + "FactoryStories\\Providers\\ServiceProvider" + ] + } + } } diff --git a/src/FactoryStory.php b/src/FactoryStory.php index 29d2088..68eeb0f 100644 --- a/src/FactoryStory.php +++ b/src/FactoryStory.php @@ -2,6 +2,7 @@ namespace FactoryStories; +use Illuminate\Support\Collection; use FactoryStories\Contracts\FactoryStoryContract; /** @@ -32,7 +33,7 @@ abstract public function build($params = []); */ public function times($amount) { - $this->times = $amount; + $this->times = (int)$amount; return $this; } @@ -46,13 +47,12 @@ public function times($amount) */ public function create($params = []) { - if (is_int($this->times) && $this->times > 1) { - return collect(range(1, $this->times)) - ->transform(function ($index) use ($params) { - return $this->build($params); - }); + if ($this->times <= 1) { + return $this->build($params); } - - return $this->build($params); + + return Collection::times($this->times, function () use ($params) { + return $this->build($params); + }); } } diff --git a/src/Providers/StoryFactoryServiceProvider.php b/src/Providers/ServiceProvider.php similarity index 78% rename from src/Providers/StoryFactoryServiceProvider.php rename to src/Providers/ServiceProvider.php index ef525d0..0ded6e2 100644 --- a/src/Providers/StoryFactoryServiceProvider.php +++ b/src/Providers/ServiceProvider.php @@ -2,10 +2,10 @@ namespace FactoryStories\Providers; -use Illuminate\Support\ServiceProvider; +use Illuminate\Support\ServiceProvider as LaravelServiceProvider; use FactoryStories\Commands\StoryMakeCommand; -class StoryFactoryServiceProvider extends ServiceProvider +class ServiceProvider extends LaravelServiceProvider { /** * Bootstrap the application services.