diff --git a/CHANGELOG.md b/CHANGELOG.md index 38a2bf3..dc87c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ All notable changes to this project will be documented in this file. ### Added - Add support of variadic parameters in `ide-helper:models` [\#1234 / shaffe-fr](https://github.com/barryvdh/laravel-ide-helper/pull/1234) +### Changed +- Move default models helper filename to config [\#1241 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1241) + 2021-06-18, 2.10.1 ------------------ ### Added diff --git a/config/ide-helper.php b/config/ide-helper.php index f512047..51fcdf2 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -13,6 +13,17 @@ return [ 'filename' => '_ide_helper.php', + /* + |-------------------------------------------------------------------------- + | Models filename + |-------------------------------------------------------------------------- + | + | The default filename for the models helper file + | + */ + + 'models_filename' => '_ide_helper_models.php', + /* |-------------------------------------------------------------------------- | Where to write the PhpStorm specific meta file diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 5ad82b8..651f37e 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -78,7 +78,11 @@ class ModelsCommand extends Command * @var string */ protected $name = 'ide-helper:models'; - protected $filename = '_ide_helper_models.php'; + + /** + * @var string + */ + protected $filename; /** * The console command description. @@ -131,7 +135,8 @@ class ModelsCommand extends Command */ public function handle() { - $filename = $this->option('filename'); + $this->filename = $this->laravel['config']->get('ide-helper.models_filename', '_ide_helper_models.php'); + $filename = $this->option('filename') ?? $this->filename; $this->write = $this->option('write'); $this->write_mixin = $this->option('write-mixin'); $this->dirs = array_merge( @@ -199,7 +204,7 @@ class ModelsCommand extends Command protected function getOptions() { return [ - ['filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the helper file', $this->filename], + ['filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the helper file'], ['dir', 'D', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The model dir, supports glob patterns', [], ], ['write', 'W', InputOption::VALUE_NONE, 'Write to Model file'],