Last active
April 15, 2016 13:27
-
-
Save antonioreyna/113f0708a36ac1cd7823611ad53eeb52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Foundation\Console\ModelMakeCommand as BaseModelMakeCommand; | |
use Symfony\Component\Console\Input\InputOption; | |
class ModelMakeCommand extends BaseModelMakeCommand | |
{ | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Create a new Eloquent model class (with optional directory)'; | |
/** | |
* Sets the default directory for models. | |
* | |
* @var string | |
*/ | |
protected $defaultDirectory = 'Models'; | |
/** | |
* Execute the console command. | |
* | |
* @return void | |
*/ | |
public function fire() | |
{ | |
if ($this->option('dir')) | |
{ | |
// concatenate the directory to the model's name | |
$model = $this->option('dir') . '/' . $this->argument('name'); | |
$this->input->setArgument('name', $model); | |
} | |
parent::fire(); | |
} | |
/** | |
* Get the console command options. | |
* | |
* @return array | |
*/ | |
protected function getOptions() | |
{ | |
return array_merge( | |
[ | |
['dir', 'd', InputOption::VALUE_OPTIONAL, 'Create the model in the given directory.', $this->defaultDirectory] | |
], parent::getOptions()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment