staskjs / laravel-rest
All you need to quickly create REST controllers
Installs: 4 630
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- staskjs/laravel-utils: ^1.1
README
Why?
Everytime projects need a REST api to work with, it finished with lots of duplicate code all over the place and what is worse, in multiple projects.
So to handle this problem, this repository was created.
For now it contains only one controller from which you can extend to get all those standard REST functions.
Controller is highly customizible by overriding some functions.
Please refer to source code to see what you can do.
Installation
composer require staskjs/laravel-rest
Then register service provider in config/app.php
:
Staskjs\Rest\RestServiceProvider::class
Then just extend your controller from \Staskjs\Rest\RestController
,
register resource
route (Route::resource
) pointing to your controller
and you are good to go!
Usage
You can add Form Request Validation to every request there is.
Simple override these parameters with class to use.
protected $storeRequest = ModelStoreRequest::class;
// Same with other requests, if needed
For simpler approach to validation, override rules
method to return array of validation rules.