PHP code example of consigliere / scaffold

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

    

consigliere / scaffold example snippets


# App\Http\Kernel.php

    ...
    protected $routeMiddleware = [
        ...
        'scopes' => \App\Components\Signature\Http\Middleware\CheckScopes::class,
        'scope'  => \App\Components\Signature\Http\Middleware\CheckForAnyScope::class,
        ...
    ];
    ...

Route::get('/orders', function () {
    // Access token has both "check-status" and "place-orders" scopes...
})->middleware('scopes:check-status,place-orders');

Route::get('/orders', function () {
    // Access token has either "check-status" or "place-orders" scope...
})->middleware('scope:check-status,place-orders');

namespace Tests;

use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Laravel\Passport\Passport;

/**
 * Class ScaffoldApiTestCase
 * @package Tests
 */
abstract class ScaffoldApiTestCase extends BaseTestCase
{
    use CreatesApplication, DatabaseTransactions;

    public function init()
    {
        $scopes = \App\Components\Scaffold\Entities\Permission::where('id', '>', 0)->pluck('key');

        Passport::actingAs(
            factory(\Api\User\Entities\User::class)->create(['role_id' => 2, 'uuid' => randomUuid(), 'username' => 'test' . mt_rand()]),
            $scopes->toArray()
        );
    }
}
bash
php artisan vendor:publish --tag=scaffold_tests --force