added env helpers

This commit is contained in:
Denis Duliçi 2022-06-13 10:01:46 +03:00
parent e34187ffe0
commit e9beb11a5f
3 changed files with 66 additions and 16 deletions

View File

@ -21,7 +21,7 @@ class App extends Provider
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class); $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
} }
if (config('app.env') !== 'production') { if (! env_is_production()) {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
} }

View File

@ -21,7 +21,7 @@ trait DateTime
$default = 'd M Y'; $default = 'd M Y';
// Make sure it's installed // Make sure it's installed
if (!config('app.installed') && (config('app.env') !== 'testing')) { if (! config('app.installed') && ! env_is_testing()) {
return $default; return $default;
} }

View File

@ -208,3 +208,53 @@ if (!function_exists('default_currency')) {
return setting('default.currency'); return setting('default.currency');
} }
} }
if (! function_exists('env_is_production')) {
/**
* Determine if the application is in the production environment
*/
function env_is_production(): bool
{
return config('app.env') === 'production';
}
}
if (! function_exists('env_is_development')) {
/**
* Determine if the application is in the development environment
*/
function env_is_development(): bool
{
return config('app.env') === 'development';
}
}
if (! function_exists('env_is_build')) {
/**
* Determine if the application is in the build environment
*/
function env_is_build(): bool
{
return config('app.env') === 'build';
}
}
if (! function_exists('env_is_local')) {
/**
* Determine if the application is in the local environment
*/
function env_is_local(): bool
{
return config('app.env') === 'local';
}
}
if (! function_exists('env_is_testing')) {
/**
* Determine if the application is in the testing environment
*/
function env_is_testing(): bool
{
return config('app.env') === 'testing';
}
}