PHP code example of dgvai / laravel-demo-mode

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

    

dgvai / laravel-demo-mode example snippets


    "DGvai\DemoMode\DemoModeServiceProvider"

    /**
         * ENABLE DEMO MODE?
         * ------------------------
         * Use from true to enable demo 
         * mode for your production env
         * 
         */

        'enabled' => env('DEMO_ENABLED',true),

        /**
         * CUSTOM FLASH VARIABLE
         * ------------------------
         * If you want to use custom flash
         * alerts like, realrashid/sweetalert2 
         * has toast_error, success, etc flash 
         * variables to show alert, then use it
         * here.
         * 
         */

        'flash' => 'demo_info',

        /**
         * CUSTOM MESSAGE
         * ------------------------
         * If you want to show a custom flash 
         * message to the users, set it here.
         * 
         */
        
        'msg' => 'Further action is disabled in demo mode!'

    Route::post('/save',function(){
        ....
        return 'Furthur Actions';
        ...
    })->middleware('demo')->name('save');

    @if(session()->has('demo_info'))
    <div class="alert alert-warning">
        {{session()->get('demo_info')}}
    </div>
    @endif
bash
    php artisan vendor:publish --tag=demomode
bash
    php artisan config:cache