diff --git a/composer.json b/composer.json index 3db6493..bc0e5e6 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,9 @@ "license": "MIT", "require": { "php": "^7.2.5", - "illuminate/support": "^6.0|^7.0", - "illuminate/console": "^6.0|^7.0", - "illuminate/filesystem": "^6.0|^7.0", + "illuminate/support": "^6.0|^7.0|^8.0", + "illuminate/console": "^6.0|^7.0|^8.0", + "illuminate/filesystem": "^6.0|^7.0|^8.0", "doctrine/dbal": "^2.9" }, "autoload": { diff --git a/resources/views/factory.blade.php b/resources/views/factory.blade.php index 4c17d52..65a77cc 100644 --- a/resources/views/factory.blade.php +++ b/resources/views/factory.blade.php @@ -1,11 +1,30 @@ -/* @@var $factory \Illuminate\Database\Eloquent\Factory */ +namespace Database\Factories; -use Faker\Generator as Faker; +use {{$reflection->getName()}}; +use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Str; -$factory->define({{ $reflection->getName() }}::class, function (Faker $faker) { - return [ +class {{$reflection->getShortName()}}Factory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = {{$reflection->getShortName()}}::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $faker = $this->faker; + return [ @foreach($properties as $name => $property) - '{{$name}}' => {!! $property !!}, + '{{$name}}' => {!! $property !!}, @endforeach - ]; -}); + ]; + } +} diff --git a/src/Console/GenerateCommand.php b/src/Console/GenerateCommand.php index 57f814e..4da37ae 100644 --- a/src/Console/GenerateCommand.php +++ b/src/Console/GenerateCommand.php @@ -31,7 +31,7 @@ class GenerateCommand extends Command /** * @var string */ - protected $dir = 'app'; + protected $dir = 'app/Models'; /** @var \Illuminate\Contracts\View\Factory */ protected $view; @@ -173,7 +173,7 @@ protected function generateFactory($model) return $output; } - + // TODO: look in app/Models instead of app for the models (Laravel 8 default) protected function loadModels($models = []) { if (!empty($models)) {