PHP code example of alexssander-cusin / panic-control-laravel

1. Go to this page and download the library: Download alexssander-cusin/panic-control-laravel 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/ */

    

alexssander-cusin / panic-control-laravel example snippets


return [
    /** 
     *--------------------------------------------------------------------------
     * Set up what store will be used
     *--------------------------------------------------------------------------
    */
    
    'default' => 'database',
    
    'drivers' => [
        'database' => [
            /**
             *--------------------------------------------------------------------------
             * Defines which registered connections
             *--------------------------------------------------------------------------
             * The storage listed in /config/database.php should be used
             */
            
            'connection' => config('database.default'),

            /** 
             *--------------------------------------------------------------------------
             * Define the table name will be created in database
             *--------------------------------------------------------------------------
            */
            
            'table' => 'panic_controls',
        ],
        'file' => [
            /** 
             *--------------------------------------------------------------------------
             * Defines which registered disk
             *--------------------------------------------------------------------------
             * The storage listed in /config/filesystem.php should be used
             * 
             * Supported Drivers: "local", "ftp", "sftp", "s3"
            */
            
            'disk' => config('filesystems.default'),
            
            /** 
             *--------------------------------------------------------------------------
             * Defines the name of the file that will be created
             *--------------------------------------------------------------------------
            */
            
            'path' => 'panic-control.json',
        ],
        'endpoint' => [
            /**
             *--------------------------------------------------------------------------
             * Defines the URL of the endpoint
             *--------------------------------------------------------------------------
             */
            'url' => 'https://localhost/panic-control.json',
        ],
    ],
    'cache' => [
        /** 
         *--------------------------------------------------------------------------
         * Activates the cache usage for the panic controls
         *--------------------------------------------------------------------------
        */
        
        'enabled' => true,
        
        /** 
         *--------------------------------------------------------------------------
         * Defines what cache store should be used
         *--------------------------------------------------------------------------
         * The storage listed in /config/cache.php should be used
         * 
         * Supported drivers: "apc", "array", "database", "file",
         *      "memcached", "redis", "dynamodb", "octane", "null"
        */
        
        'store' => env('CACHE_DRIVER', 'file'),

        /**
         *--------------------------------------------------------------------------
         * Cache Key Prefix
         *--------------------------------------------------------------------------
         *
         * When utilizing the APC, database, memcached, Redis, or DynamoDB cache
         * stores there might be other applications using the same cache. For
         * that reason, you may prefix every cache key to avoid collisions.
         *
        */

        'key' => 'panic-control',

        /**
         *--------------------------------------------------------------------------
         * Sets the time the cache will expire
         *--------------------------------------------------------------------------
        */

        'ttl' => 60,
    ],

    /**
     *--------------------------------------------------------------------------
     * List custom rules
     *--------------------------------------------------------------------------
    */

    'rules' => [
        'route-name' => PanicControl\Rules\RouteName::class,
        'url-path' => PanicControl\Rules\UrlPath::class,
        'sampling' => PanicControl\Rules\Sampling::class,
        'user' => PanicControl\Rules\User::class,
    ],
];

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => false,
]);

use PanicControl\Facades\PanicControl;

$panic = 'panic-control-name'; //Panic Control Name or ID

PanicControl::edit($panic, [
    'name' => 'new-panic-control-name',
]);

use PanicControl\Facades\PanicControl;

PanicControl::all();

use PanicControl\Facades\PanicControl;

PanicControl::find('panic-control-name');

use PanicControl\Facades\PanicControl;

PanicControl::check('panic-control-name');

getPanicControlActive('panic-control-name');

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'route-name' => [
            'route.name.home',
            'route.name.contact'
        ],
    ],
]);

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'url-path' => [
            'url/path/home',
            'url/path/contact'
        ],
    ],
]);

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'rules' => [
            'sampling' => [
                'chance' => 5,
                'out_of' => 10,
            ],
        ],
    ],
]);

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'rules' => [
            'user' => [
                1, //User ID
                '[email protected]', //User EMAIL
            ],
        ],
    ],
]);

use PanicControl\Rules\Rule;
use PanicControl\Contracts\RuleContract;

class ClassName extends Rule implements RuleContract
{
    public function rule(array $parameters): bool|null
    {
        return false|true|null;
    }
}

return [
    ...
    'rules' => [
        'class-name' => Namespace/ClassName::class,
    ],
];

use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'class-name' => 'parameters',
    ],
]);

use PanicControl\Facades\PanicControl;

PanicControl::driver('file')->count()

use PanicControl\Facades\PanicControl;

PanicControl::extend('other', function(){
  return return new OtherDrive();
});
bash
php artisan vendor:publish --tag="panic-control-laravel-config"
bash
php artisan vendor:publish --tag="panic-control-laravel-migrations"
php artisan migrate
bash
php artisan panic-control:list