Skip to content

Commit

Permalink
Merge pull request #85 from MohamedKhedr700/bugfix/existing-trait
Browse files Browse the repository at this point in the history
Enhance pass existing trait
  • Loading branch information
hassanzohdy committed Jul 20, 2022
2 parents 8fb2e40 + e9640b6 commit 895ca3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
12 changes: 0 additions & 12 deletions module/Models/model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ class {{ ModelName }} extends Model
*/
const MODEL_LINKS_ARRAY = [];

/**
* Define list of other models that will be affected as the current object is part of array
* as the current model is sub-document to it when it gets created
*
* @example ModelClass::class => searchingColumn will be converted to ['searchingColumn['id'], 'columnName', 'sharedInfo']
* @example ModelClass::class => [searchingColumn, creatingColumn]
* @example ModelClass::class => [searchingColumn, creatingColumn, sharedInfoMethod]
*
* @const array
*/
const ON_MODEL_CREATE_PUSH = [];

/**
* Define list of other models that will be affected
* as the current model is sub-document to it when it gets created
Expand Down
8 changes: 5 additions & 3 deletions src/Console/Commands/EngezTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function handle()
{
$this->init();

$this->validateArguments();
if ($this->validateArguments() === false) return;

$this->create();

Expand Down Expand Up @@ -86,13 +86,15 @@ public function validateArguments()
parent::validateArguments();

if (!in_array($this->option('type'), [static::TYPE_GENERAL, static::TYPE_REQUEST])) {
return $this->missingRequiredOption('This controller type does not exits, Did you mean? ' . implode(PHP_EOL, static::TRAIT_TYPES));
return $this->missingRequiredOption('This trait type does not exits, Did you mean? ' . implode(PHP_EOL, static::TRAIT_TYPES));
}

$baseDir = $this->isRequestTrait() ? 'Traits/Validation' : 'Traits';

if ($this->files->exists($this->modulePath("$baseDir/$this->traitName.php"))) {
return $this->info('You already have this trait');
$this->info('You already have this trait');

return false;
}
}

Expand Down

0 comments on commit 895ca3f

Please sign in to comment.