hasandotprayoga / basic-crud
There is no license information available for the latest version (v1.2.7) of this package.
Laravel Basic CRUD for rest API
v1.2.7
2019-03-15 08:58 UTC
Requires
README
Installation
Add to composer.json
"require": {
...
"hasandotprayoga/basic-crud": "*"
}
On your terminal, run composer update
Configuration
This package require hasandotprayoga/format-resposne
for response. See configuration for this package FormatResponse.
-
Create model for eloquent.
-
Create controller and see how to configure:
<?php namespace App\Http\Controllers; class ExampleController extends Controller { use \BasicCrud\BasicCrud; // call trait public $model = \App\Models\Fakers::class; // variable for your model public $dataDelete = ['field_name'=>'value']; // if use soft delete // variable for insert validation public $insertValidation = [ 'field1'=>'required', 'field2'=>'required|numeric', 'field3'=>'required' ]; // variable for update validation public $updateValidation = [ 'field1'=>'required', 'field2'=>'required|numeric', 'field3'=>'required' ]; }
-
Add to route this:
... $router->get('/examples', ['as'=>'read','uses'=>'ExamplesController@index']); $router->post('/examples', ['as'=>'create','uses'=>'ExamplesController@store']); $router->put('/examples', ['as'=>'update','uses'=>'ExamplesController@update']); $router->delete('/examples/{id}[/{type}]', ['as'=>'delete','uses'=>'ExamplesController@destroy']);
Implementation
Check this https://github.com/hasandotprayoga/basic-crud-implementation