Skip to content

Commit

Permalink
Move default models filename to config
Browse files Browse the repository at this point in the history
  • Loading branch information
wimski committed Aug 8, 2021
1 parent 52a4b64 commit 46fea3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions config/ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

'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
Expand Down
11 changes: 8 additions & 3 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -131,7 +135,8 @@ public function __construct(Filesystem $files)
*/
public function handle()
{
$filename = $this->option('filename');
$this->filename = $this->laravel['config']->get('ide-helper.models_filename');
$filename = $this->option('filename') ?? $this->filename;
$this->write = $this->option('write');
$this->write_mixin = $this->option('write-mixin');
$this->dirs = array_merge(
Expand Down Expand Up @@ -199,7 +204,7 @@ protected function getArguments()
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'],
Expand Down
3 changes: 3 additions & 0 deletions tests/Console/ModelsCommand/AbstractModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ protected function getEnvironmentSetUp($app)
'prefix' => '',
]);

// Set the default models helper filename
$config->set('ide-helper.models_filename', '_ide_helper_models.php');

// Load the Models from the Test dir
$config->set('ide-helper.model_locations', [
dirname((new \ReflectionClass(static::class))->getFileName()) . '/Models',
Expand Down

0 comments on commit 46fea3a

Please sign in to comment.