2023-07-10 21:42:55 +06:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Helpers;
|
|
|
|
|
2023-12-05 00:53:04 +06:00
|
|
|
use App\Models\User;
|
2023-07-10 21:42:55 +06:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
|
|
final readonly class Helpers
|
|
|
|
{
|
|
|
|
public static function getTimeZoneList(): Collection
|
|
|
|
{
|
|
|
|
return Cache::rememberForever('timezones_list_collection', function () {
|
|
|
|
$timezone = [];
|
|
|
|
foreach (timezone_identifiers_list(\DateTimeZone::ALL) as $key => $value) {
|
|
|
|
$timezone[$value] = $value . ' (UTC ' . now($value)->format('P') . ')';
|
|
|
|
}
|
|
|
|
return collect($timezone)->sortKeys();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getUserTimeZone() {
|
|
|
|
return auth()->user()?->timezone ?? config('app.user_timezone');
|
|
|
|
}
|
2023-12-05 00:53:04 +06:00
|
|
|
|
|
|
|
public static function isDemoMode(): bool
|
|
|
|
{
|
|
|
|
return config('app.demo_mode', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function isDemoModeAndUserDenyUpdate(User $user): bool
|
|
|
|
{
|
|
|
|
if (self::isDemoMode() !== true) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $user->email === config('app.demo_email');
|
|
|
|
}
|
2023-07-10 21:42:55 +06:00
|
|
|
}
|