-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new 'module:make-request' console command. Fix #155
- Loading branch information
Gravitano
committed
May 17, 2015
1 parent
c5bbf71
commit ab9fc26
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php namespace Pingpong\Modules\Commands; | ||
|
||
use Illuminate\Support\Str; | ||
use Pingpong\Generators\Stub; | ||
use Pingpong\Modules\Traits\ModuleCommandTrait; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class MakeRequestCommand extends GeneratorCommand { | ||
|
||
use ModuleCommandTrait; | ||
|
||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'module:make-request'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Generate new form request class for the specified module.'; | ||
|
||
/** | ||
* Get the console command arguments. | ||
* | ||
* @return array | ||
*/ | ||
protected function getArguments() | ||
{ | ||
return array( | ||
array('name', InputArgument::REQUIRED, 'The name of the form request class.'), | ||
array('module', InputArgument::OPTIONAL, 'The name of module will be used.'), | ||
); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getTemplateContents() | ||
{ | ||
return (new Stub('/request.stub', [ | ||
'MODULE' => $this->getModuleName(), | ||
'NAME' => $this->getFileName(), | ||
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') | ||
]))->render(); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getDestinationFilePath() | ||
{ | ||
$path = $this->laravel['modules']->getModulePath($this->getModuleName()); | ||
|
||
$seederPath = $this->laravel['modules']->config('paths.generator.request'); | ||
|
||
return $path . $seederPath . '/' . $this->getFileName() . '.php'; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getFileName() | ||
{ | ||
return Str::studly($this->argument('name')); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php namespace $MODULE_NAMESPACE$\$MODULE$\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class $NAME$ extends FormRequest { | ||
|
||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
} |
This file contains 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