Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save antonioreyna/113f0708a36ac1cd7823611ad53eeb52 to your computer and use it in GitHub Desktop.
Save antonioreyna/113f0708a36ac1cd7823611ad53eeb52 to your computer and use it in GitHub Desktop.
<?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