Skip to content

Commit

Permalink
Laravel 5.5 package auto-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffochoa committed Sep 6, 2017
1 parent c09c43a commit b450892
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"homepage": "https://github.com/jeffochoa/factory-stories",
"license": "MIT",
"version": "1.0",
"version": "1.1",
"authors": [
{
"name": "Jeff Ochoa"
Expand All @@ -18,5 +18,12 @@
"FactoryStories\\": "src/"
}
},
"require": {}
"require": {},
"extra": {
"laravel": {
"providers": [
"FactoryStories\\Providers\\ServiceProvider"
]
}
}
}
16 changes: 8 additions & 8 deletions src/FactoryStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FactoryStories;

use Illuminate\Support\Collection;
use FactoryStories\Contracts\FactoryStoryContract;

/**
Expand Down Expand Up @@ -32,7 +33,7 @@ abstract public function build($params = []);
*/
public function times($amount)
{
$this->times = $amount;
$this->times = (int)$amount;

return $this;
}
Expand All @@ -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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b450892

Please sign in to comment.