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

@ -6,7 +6,7 @@ use App\Traits\Sources;
use App\Utilities\Date; use App\Utilities\Date;
use App\Utilities\Widgets; use App\Utilities\Widgets;
if (!function_exists('user')) { if (! function_exists('user')) {
/** /**
* Get the authenticated user. * Get the authenticated user.
* *
@ -18,7 +18,7 @@ if (!function_exists('user')) {
} }
} }
if (!function_exists('user_id')) { if (! function_exists('user_id')) {
/** /**
* Get id of current user. * Get id of current user.
* *
@ -30,7 +30,7 @@ if (!function_exists('user_id')) {
} }
} }
if (!function_exists('company_date_format')) { if (! function_exists('company_date_format')) {
/** /**
* Get the date format of company. * Get the date format of company.
* *
@ -46,7 +46,7 @@ if (!function_exists('company_date_format')) {
} }
} }
if (!function_exists('company_date')) { if (! function_exists('company_date')) {
/** /**
* Format the given date based on company settings. * Format the given date based on company settings.
* *
@ -58,7 +58,7 @@ if (!function_exists('company_date')) {
} }
} }
if (!function_exists('show_widget')) { if (! function_exists('show_widget')) {
/** /**
* Show a widget. * Show a widget.
* *
@ -74,7 +74,7 @@ if (!function_exists('show_widget')) {
} }
} }
if (!function_exists('company')) { if (! function_exists('company')) {
/** /**
* Get current/any company model. * Get current/any company model.
* *
@ -98,7 +98,7 @@ if (!function_exists('company')) {
} }
} }
if (!function_exists('company_id')) { if (! function_exists('company_id')) {
/** /**
* Get id of current company. * Get id of current company.
* *
@ -110,7 +110,7 @@ if (!function_exists('company_id')) {
} }
} }
if (!function_exists('should_queue')) { if (! function_exists('should_queue')) {
/** /**
* Check if queue is enabled. * Check if queue is enabled.
* *
@ -121,7 +121,7 @@ if (!function_exists('should_queue')) {
} }
} }
if (!function_exists('source_name')) { if (! function_exists('source_name')) {
/** /**
* Get the current source. * Get the current source.
* *
@ -139,7 +139,7 @@ if (!function_exists('source_name')) {
} }
} }
if (!function_exists('cache_prefix')) { if (! function_exists('cache_prefix')) {
/** /**
* Cache system added company_id prefix. * Cache system added company_id prefix.
* *
@ -151,7 +151,7 @@ if (!function_exists('cache_prefix')) {
} }
} }
if (!function_exists('array_values_recursive')) { if (! function_exists('array_values_recursive')) {
/** /**
* Get array values recursively. * Get array values recursively.
*/ */
@ -171,7 +171,7 @@ if (!function_exists('array_values_recursive')) {
} }
} }
if (!function_exists('running_in_queue')) { if (! function_exists('running_in_queue')) {
/** /**
* Detect if application is running in queue. * Detect if application is running in queue.
* *
@ -183,7 +183,7 @@ if (!function_exists('running_in_queue')) {
} }
} }
if (!function_exists('simple_icons')) { if (! function_exists('simple_icons')) {
/** /**
* Get the simple icon content * Get the simple icon content
* *
@ -197,7 +197,7 @@ if (!function_exists('simple_icons')) {
} }
} }
if (!function_exists('default_currency')) { if (! function_exists('default_currency')) {
/** /**
* Get the default currency code * Get the default currency code
* *
@ -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';
}
}