PHP code example of crixuamg / laravel-decorators

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

    

crixuamg / laravel-decorators example snippets


    use \CrixuAMG\Decorators\Http\Controllers\AbstractController;

    class UserController extends AbstractController {
        public function __construct()
        {
            $this->setup('users', UserResource::class);
        }

        public function index() {
           return $this->forwardResourceful(__FUNCTION__);
        }
     }
    

        'tree' => [
            'users'                => [
                'contract'  => App\Contracts\UserContract::class,
                'arguments' => [
                    // First element is the deepest layer
                    App\Repositories\UserRepository::class,
                    App\Caches\UserCache::class,
                    App\Decorators\UserDecorator::class,
                ],
            ],
        ]
    
bash
    php artisan decorator:cache      ModelCache
    php artisan decorator:repository ModelRepository
    php artisan decorator:contract   ModelContract
bash
    php artisan decorators:make User
bash
    php artisan decorators:starter User