Skip to content

Support for laravel 8 #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
33 changes: 26 additions & 7 deletions resources/views/factory.blade.php
Original file line number Diff line number Diff line change
@@ -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
];
});
];
}
}
4 changes: 2 additions & 2 deletions src/Console/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GenerateCommand extends Command
/**
* @var string
*/
protected $dir = 'app';
protected $dir = 'app/Models';

/** @var \Illuminate\Contracts\View\Factory */
protected $view;
Expand Down Expand Up @@ -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)) {
Expand Down