Tweak multiple models

Use array instead of comma seperated
This commit is contained in:
Barry vd. Heuvel
2014-02-07 10:05:51 +01:00
parent caeb0227b6
commit e6493fd9e8
2 changed files with 12 additions and 7 deletions
+4 -2
View File
@@ -75,11 +75,13 @@ With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly
By default, models in app/models are scanned. The optional argument tells what models to use (also outside app/models). By default, models in app/models are scanned. The optional argument tells what models to use (also outside app/models).
php artisan ide-helper:models Post,User php artisan ide-helper:models Post User
You can also scan a different directory, using the --dir option (relative from the base path): You can also scan a different directory, using the --dir option (relative from the base path):
php artisan ide-helper:models --dir="app/workbench/name/package/models" php artisan ide-helper:models --dir="app/workbench/name/package/models" --dir="app/src/Model"
You can publish the config file (`php artisan config:publisb barryvdh/laravel-idehelper`) and set the default directories.
Models can be ignored using the --ignore (-I) option Models can be ignored using the --ignore (-I) option
@@ -63,7 +63,7 @@ class ModelsCommand extends Command {
//If filename is default and Write is not specified, ask what to do //If filename is default and Write is not specified, ask what to do
if(!$this->write && $filename === $this->filename && !$this->option('nowrite')){ if(!$this->write && $filename === $this->filename && !$this->option('nowrite')){
if($this->confirm("Do you want to overwrite the existing model files for '$model'? Choose no to write to $filename instead? (Yes/No): ")){ if($this->confirm("Do you want to overwrite the existing model files? Choose no to write to $filename instead? (Yes/No): ")){
$this->write = true; $this->write = true;
} }
} }
@@ -89,7 +89,7 @@ class ModelsCommand extends Command {
protected function getArguments() protected function getArguments()
{ {
return array( return array(
array('model', InputArgument::OPTIONAL, 'Which models to include', '*'), array('model', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Which models to include', array()),
); );
} }
@@ -110,7 +110,7 @@ class ModelsCommand extends Command {
); );
} }
protected function generateDocs($model, $ignore = ''){ protected function generateDocs($loadModels, $ignore = ''){
$output = "<?php $output = "<?php
@@ -123,10 +123,13 @@ class ModelsCommand extends Command {
*/ */
\n\n"; \n\n";
if($model === '*'){ if(empty($loadModels)){
$models = $this->loadModels(); $models = $this->loadModels();
}else{ }else{
$models = explode(',', $model); $models = array();
foreach($loadModels as $model){
$models = array_merge($models, explode(',', $model));
}
} }
$ignore = explode(',', $ignore); $ignore = explode(',', $ignore);