Initial Commit
This commit is contained in:
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace mpba\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use mpba\Modules\Support\Config\GenerateConfigReader;
|
||||
use mpba\Modules\Support\Stub;
|
||||
use mpba\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class FactoryMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-factory';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new model factory for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the factory.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
return (new Stub('/factory.stub'))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$factoryPath = GenerateConfigReader::read('factory');
|
||||
|
||||
return $path.$factoryPath->getPath().'/'.$this->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name')).'.php';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user