Skip to content
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

[6.x] Add ability to create seeder when creating the model #30828

Merged
merged 2 commits into from Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Illuminate/Foundation/Console/ModelMakeCommand.php
Expand Up @@ -55,6 +55,10 @@ public function handle()
$this->createMigration();
}

if ($this->option('seed')) {
$this->createSeeder();
}

if ($this->option('controller') || $this->option('resource')) {
$this->createController();
}
Expand Down Expand Up @@ -94,6 +98,20 @@ protected function createMigration()
]);
}

/**
* Create a seeder file for the model.
*
* @return void
*/
protected function createSeeder()
{
$seederName = Str::plural(Str::ucfirst($this->argument('name')));

$this->call('make:seed', [
'name' => "{$seederName}Seeder",
]);
}

/**
* Create a controller for the model.
*
Expand Down Expand Up @@ -143,6 +161,8 @@ protected function getOptions()

['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model'],

['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder file for the model'],

['pivot', 'p', InputOption::VALUE_NONE, 'Indicates if the generated model should be a custom intermediate table model'],

['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
Expand Down