Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
vendor
/
nwidart
/
laravel-modules
/
src
/
Commands
:
FactoryMakeCommand.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Nwidart\Modules\Commands; use Illuminate\Support\Str; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\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'; } }