feature - 17 - Add mode config
This commit is contained in:
parent
0baa87e373
commit
b1cf8b5f22
4 changed files with 56 additions and 0 deletions
24
app/Enums/AppModeEnum.php
Normal file
24
app/Enums/AppModeEnum.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum AppModeEnum: string
|
||||
{
|
||||
case APP = 'app';
|
||||
case SAAS = 'saas';
|
||||
|
||||
public static function current(): self
|
||||
{
|
||||
return self::from(config('app.mode', 'app'));
|
||||
}
|
||||
|
||||
public function isApp(): bool
|
||||
{
|
||||
return $this === self::APP;
|
||||
}
|
||||
|
||||
public function isSaas(): bool
|
||||
{
|
||||
return $this === self::SAAS;
|
||||
}
|
||||
}
|
||||
17
app/helpers.php
Normal file
17
app/helpers.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\AppModeEnum;
|
||||
|
||||
if (! function_exists('is_mode_app')) {
|
||||
function is_mode_app(): bool
|
||||
{
|
||||
return AppModeEnum::current()->isApp();
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('is_mode_saas')) {
|
||||
function is_mode_saas(): bool
|
||||
{
|
||||
return AppModeEnum::current()->isSaas();
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,9 @@
|
|||
"phpunit/phpunit": "^11.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"DishPlanner\\": "src/DishPlanner/",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,18 @@
|
|||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines the application deployment mode: 'app' for self-hosted,
|
||||
| 'saas' for multi-tenant SaaS, 'demo' for demonstration instances.
|
||||
|
|
||||
*/
|
||||
|
||||
'mode' => env('APP_MODE', 'app'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|
|
|
|||
Loading…
Reference in a new issue