1. Go to this page and download the library: Download spatie/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/ */
return [
/*
* This is the master switch to enable demo mode.
*/
'enabled' => env('DEMO_MODE_ENABLED', true),
/*
* Visitors browsing a protected url will be redirected to this path.
*/
'redirect_unauthorized_users_to_url' => '/under-construction',
/*
* After having gained access, visitors will be redirected to this path.
*/
'redirect_authorized_users_to_url' => '/',
/*
* The following IP's will automatically gain access to the
* app without having to visit the `demoAccess` route.
*/
'authorized_ips' => [
//
],
/*
* When strict mode is enabled, only IP's listed in `authorized_ips` will gain access.
* Visitors won't be able to gain access by visiting the `demoAccess` route anymore.
*/
'strict_mode' => false,
];
Route::demoAccess('/demo');
//only users who have previously visited "/demo" will be able to see these pages.
Route::group(['middleware' => 'demoMode'], function () {
Route::get('/secret-route', function() {
echo 'Hi!';
});
});