Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Console/Commands/CrudBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CrudBackpackCommand extends BackpackCommand
* @var string
*/
protected $signature = 'backpack:crud {name}
{--validation= : Validation type, must be request, array or field}';
{--validation= : Validation type, must be request, array or field} {--force}';

/**
* The console command description.
Expand Down Expand Up @@ -52,14 +52,14 @@ public function handle()
}

// Create the CRUD Model and show output
$this->call('backpack:crud-model', ['name' => $name]);
$this->call('backpack:crud-model', ['name' => $nameTitle, '--force' => $this->option('force')]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably store the --force option up close where we init other command properties like $name, $nameTitle etc. We then re-use the variable across the command 👍 This is just personal preference, it's not that is bad implemented.

Suggested change
$this->call('backpack:crud-model', ['name' => $nameTitle, '--force' => $this->option('force')]);
$this->call('backpack:crud-model', ['name' => $nameTitle, '--force' => $force]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also take a look at this @karandatwani92 let me know if you think we shouldn't do this, otherwise please do it 👍


// Create the CRUD Controller and show output
$this->call('backpack:crud-controller', ['name' => $name, '--validation' => $validation]);
$this->call('backpack:crud-controller', ['name' => $nameTitle, '--validation' => $validation, '--force' => $this->option('force')]);

// Create the CRUD Request and show output
if ($validation === 'request') {
$this->call('backpack:crud-request', ['name' => $name]);
$this->call('backpack:crud-request', ['name' => $nameTitle, '--force' => $this->option('force')]);
}

// Create the CRUD route
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CrudControllerBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CrudControllerBackpackCommand extends BackpackCommand
* @var string
*/
protected $signature = 'backpack:crud-controller {name}
{--validation=request : Validation type, must be request, array or field}';
{--validation=request : Validation type, must be request, array or field} {--force}';

/**
* The console command description.
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/CrudModelBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CrudModelBackpackCommand extends BackpackCommand
*
* @var string
*/
protected $signature = 'backpack:crud-model {name}';
protected $signature = 'backpack:crud-model {name} {--force}';

/**
* The console command description.
Expand Down Expand Up @@ -69,7 +69,7 @@ public function handle()
// If no model was found, we will generate the path to the location where this class file
// should be written. Then, we will build the class and make the proper replacements on
// the stub files so that it gets the correctly formatted namespace and class name.
if (! $existsOnApp && ! $existsOnModels) {
if ($this->option('force') || (! $existsOnApp && ! $existsOnModels)) {
$this->makeDirectory($this->getPath($namespaceModels));

$this->files->put($this->getPath($namespaceModels), $this->sortImports($this->buildClass($nameTitle)));
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CrudRequestBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CrudRequestBackpackCommand extends BackpackCommand
*
* @var string
*/
protected $signature = 'backpack:crud-request {name}';
protected $signature = 'backpack:crud-request {name} {--force}';

/**
* The console command description.
Expand Down