PHP code example of imfranq / laravel-resource

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

    

imfranq / laravel-resource example snippets


use ImFranq\LaravelResource\Traits\FullResource;

class TestController extends Controller
{
    use FullResource;

    public function __construct(){
        $this->moduleName = 'users';
        $this->eloquentModel = \App\Models\User::class
        // $this->onlyJsonResponse = true;
        $this->redirectTo = '/users'; // optional if onlyJsonResponse is enabled
    }
}

class UserController extends Controller
{
    use FullResource {
        create as protected createResource;
        // update as protected updateResource;
        // destroy as protected destroyResource;
    }

    public function __construct(){
        // ...
    }

    public function create(CustomRequest $request){
        // ... Code
        return $this->createResource($request);
    }
}