Skip to content

Commit

Permalink
Merge pull request #91 from ssi-anik/form-request
Browse files Browse the repository at this point in the history
Form request command added for anik/form-request package
  • Loading branch information
joelhy authored Jul 17, 2020
2 parents e01443d + 6328297 commit 0986f30
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ make:notification Create a new notification class
make:pipe Create a new pipe class
make:policy Create a new policy class
make:provider Create a new service provider class
make:request Create a new form request class
make:seeder Create a new seeder class
make:test Create a new test class
Expand Down
48 changes: 48 additions & 0 deletions src/LumenGenerator/Console/RequestMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Flipbox\LumenGenerator\Console;

class RequestMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:request';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new form request class';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Request';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/stubs/request.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Http\Requests';
}
}
30 changes: 30 additions & 0 deletions src/LumenGenerator/Console/stubs/request.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace DummyNamespace;

use Anik\Form\FormRequest;

class DummyClass extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
protected function authorize()
{
return false;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
protected function rules()
{
return [
//
];
}
}
11 changes: 11 additions & 0 deletions src/LumenGenerator/LumenGeneratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class LumenGeneratorServiceProvider extends ServiceProvider
'ControllerMake' => 'command.controller.make',
'EventMake' => 'command.event.make',
'ExceptionMake' => 'command.exception.make',
'RequestMake' => 'command.request.make',
'JobMake' => 'command.job.make',
'ListenerMake' => 'command.listener.make',
'MailMake' => 'command.mail.make',
Expand Down Expand Up @@ -223,6 +224,16 @@ protected function registerMiddlewareMakeCommand()
});
}

/**
* Register the command.
*/
protected function registerRequestMakeCommand()
{
$this->app->singleton('command.request.make', function ($app) {
return new Console\RequestMakeCommand($app['files']);
});
}

/**
* Register the command.
*/
Expand Down

0 comments on commit 0986f30

Please sign in to comment.