PHP code example of hasandotprayoga / basic-crud

1. Go to this page and download the library: Download hasandotprayoga/basic-crud library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hasandotprayoga / basic-crud example snippets


     

    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'=>'

    ...
    $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']);