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.
You can install the package via composer:
composer require dgvai/laravel-demo-mode
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"
/**
* 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!'
php artisan config:cache
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.
Please see CHANGELOG for more information what has changed recently.
The MIT License (MIT). Please see License File for more information.