-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Luke Towers <github@luketowers.ca>
- Loading branch information
1 parent
5a1fa57
commit 1a3b477
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php namespace System\Console; | ||
|
||
use System\Console\BaseScaffoldCommand; | ||
|
||
class CreateFactory extends BaseScaffoldCommand | ||
{ | ||
/** | ||
* @var string|null The default command name for lazy loading. | ||
*/ | ||
protected static $defaultName = 'create:factory'; | ||
|
||
/** | ||
* @var string The name and signature of this command. | ||
*/ | ||
protected $signature = 'create:factory | ||
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>} | ||
{factory : The name of the factory to generate. <info>(eg: PostFactory)</info>} | ||
{--m|model= : The name of the model. <info>(eg: Post)</info>} | ||
{--f|force : Overwrite existing files with generated files.} | ||
{--uninspiring : Disable inspirational quotes} | ||
'; | ||
|
||
/** | ||
* @var string The console command description. | ||
*/ | ||
protected $description = 'Creates a new factory.'; | ||
|
||
/** | ||
* @var array List of commands that this command replaces (aliases) | ||
*/ | ||
protected $replaces = [ | ||
'make:factory', | ||
]; | ||
|
||
/** | ||
* @var string The type of class being generated. | ||
*/ | ||
protected $type = 'Factory'; | ||
|
||
/** | ||
* @var string The argument that the generated class name comes from | ||
*/ | ||
protected $nameFrom = 'factory'; | ||
|
||
/** | ||
* @var array A mapping of stubs to generated files. | ||
*/ | ||
protected $stubs = [ | ||
'scaffold/factory/factory.stub' => 'database/factories/{{studly_name}}.php', | ||
]; | ||
|
||
protected function processVars($vars): array | ||
{ | ||
$vars = parent::processVars($vars); | ||
|
||
$vars['model'] = $this->option('model'); | ||
|
||
return $vars; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace {{ plugin_namespace }}\Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* {{ name }} Factory | ||
{% if model %} | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\{{ plugin_namespace }}\Models\{{ model }}> | ||
{% endif %} | ||
*/ | ||
class {{ studly_name }} extends Factory | ||
{ | ||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |