Helper method to make it easier (shorter) to determine if the app is in demo mode

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-03-21 18:59:03 -07:00
parent f29e813332
commit d55ae44638

View file

@ -150,6 +150,32 @@ class SettingsServiceProvider extends ServiceProvider
// Set the monetary locale to the configured locale to make helper::parseFloat work. // Set the monetary locale to the configured locale to make helper::parseFloat work.
setlocale(LC_MONETARY, config('app.locale')); setlocale(LC_MONETARY, config('app.locale'));
setlocale(LC_NUMERIC, config('app.locale')); setlocale(LC_NUMERIC, config('app.locale'));
/*
* This is a shorter way to see if the app is in demo mode.
*
* This makes it cleanly available in blades and in controllers, e.g.
*
* Blade:
* {{ app('demo_mode') ? ' disabled' : ''}} for form blades where we need to disable a form
*
* Controller:
* if (app('demo_mode')) {
* // don't allow the thing
* }
* @todo - use this everywhere else in the app where we have very long if/else config('app.lock_passwords') stuff
*/
\App::singleton('demo_mode', function () {
if (config('app.lock_passwords') === true) {
return true;
}
return false;
});
} }
/** /**