generated from beyondCRUD/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from RapidKit/feature/request-class-based-on-base
feature: generate request class based on base
- Loading branch information
Showing
7 changed files
with
78 additions
and
7 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
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
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RapidKit\LaravelRestify\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
class GenerateRequestCommand extends GeneratorCommand | ||
{ | ||
public $signature = 'restify:gen-request {name}'; | ||
|
||
public $description = 'Generate a new Restify request class for storing resource.'; | ||
|
||
protected function getStub() | ||
{ | ||
return __DIR__.'/../../stubs/request.stub'; | ||
} | ||
|
||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return $rootNamespace.'\Http\Requests'; | ||
} | ||
|
||
protected function replaceClass($stub, $name) | ||
{ | ||
$class = str_replace($this->getNamespace($name).'\\', '', $name); | ||
|
||
// Do string replacement | ||
return str_replace('{{ name }}', $class, $stub); | ||
} | ||
} |
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
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
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,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Data\AuthorData as DTO; // TODO: sesuaikan class model | ||
use RapidKit\LaravelRestify\Bases\BaseRequest; | ||
|
||
class {{ name }} extends BaseRequest | ||
{ | ||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public function toDto() | ||
{ | ||
return DTO::from(...$this->validated()); | ||
} | ||
} |
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