PHP code example of chriskelemba / auto-crud

1. Go to this page and download the library: Download chriskelemba/auto-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/ */

    

chriskelemba / auto-crud example snippets




namespace App\Http\Controllers;

use AutoCrud\Http\Controllers\Controller;

class UserController extends Controller
{
    //
}



namespace App\Http\Controllers;

use AutoCrud\Http\Controllers\Controller;

class UserController extends Controller
{
    //
}



namespace App\Support;

class ApiResponseFormatter
{
    public function success($data = null, string $message = 'OK', int $code = 200)
    {
        return response()->json([
            'data' => $data,
            'meta' => ['message' => $message],
        ], $code);
    }

    public function error(string $message = 'Error', int $code = 400, $errors = null)
    {
        return response()->json([
            'errors' => [[
                'status' => (string) $code,
                'detail' => $message,
                'meta' => ['errors' => $errors],
            ]],
        ], $code);
    }
}

// config/autocrud.php
'response_formatter' => \App\Support\ApiResponseFormatter::class,