dgvai / laravel-demo-mode
Your Project Protector in Online Markets
This package is auto-updated.
Last update: 2024-10-23 17:54:43 UTC
README
This package protects your projects in online market. Sometimes, in markets, the trial users uploads/saves/changes arbitrary informations that destroys the beauty of your project for the next visitors. This package comes to play in those cases.
Contents
Installation
You can install the package via composer:
composer require dgvai/laravel-demo-mode
Publish Configuration
Publish configuration file
php artisan vendor:publish --tag=demomode
For users bellow laravel < 5.5 Add service provider to config/app.php
"DGvai\DemoMode\DemoModeServiceProvider"
Setup and configure
/** * 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!'
After Done Configuration
php artisan config:cache
Usage
Simply use a middleware demo
to the routes you want to protect. Such has save routes.
Route::post('/save',function(){ .... return 'Furthur Actions'; ... })->middleware('demo')->name('save');
To show the flash message, like an alert, into your view:
@if(session()->has('demo_info')) <div class="alert alert-warning"> {{session()->get('demo_info')}} </div> @endif
Or if you have used any custom flash, like realrashid/sweetalert2
has toast_success
flash, it will automatically show the toast.
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.