venya / lp-rest
Зависимость для работы с REST АПИ для Lumen | Laravel
Installs: 4 403
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7.0.0
Requires (Dev)
- illuminate/routing: ^5.4
- laravel/lumen-framework: 5.4.*
- phpunit/phpunit: ~4.0
- dev-master
- 1.4.1
- 1.4.0
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3
- 1.2.1
- 1.2.0
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.2
- 0.1.1
- 0.0.20
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This package is auto-updated.
Last update: 2024-11-28 00:20:30 UTC
README
#Lp api rest
This package allows you to create a simple REST API on the basis of standard models (Eloquent) of the Larave 5.x Framework.
##install
- composer require venya/lp-rest
##Configure
-
Add app.php
$app->register(LpRest\RestServiceProvider::class); //$app->register(LpRest\RestServiceProviderLumen::class); //for Lumen
-
Add in AppServiceProvider::register
//Set model aliases app()->afterResolving(CommonRepositoryModelProvider::class, function(CommonRepositoryModelProvider $mp) { $mp->addModelAliases('user', \App\User::class); }); //Change access provider $this->app->bind(CommonRepositoryAccessProvider::class, ApiAccessProvider::class ); //Change response schema $this->app->bind(CommonResponse::class, ApiCustomResponse::class ); //Custom routes and etc $this->app->afterResolving(RestServiceHelper::class, function(RestServiceHelper $sp) { $sp->setRouteGroupOptions([ 'prefix' => 'api/rest', //'middleware' => 'auth', ]); });
##API
- GET /api/rest/:modelName[/:relations] - get all items
- GET /api/rest/:modelName/:id[/:relations] - get one item
- POST /api/rest/:modelName {:json body} - create item
- PUT /api/rest/:modelName/:id {:json body} - update item
- DELETE /api/rest/:modelName/:id - remove item
- POST /api/rest/:modelName/:id {:json body - arguments} - Call model method
- POST /api/rest/multi {:json body - config any query} - Causes several methods at a time
TODO FILTER DESCRIPTION
- /api/rest/file?filter[]=created_at:range:2018-03-01,2018-05-20&filter[]=tags.id:1&filter[]=id:in:1,2,3,18