diff --git a/app/Http/Controllers/Admin/AirportController.php b/app/Http/Controllers/Admin/AirportController.php index f01f3166..3129e5c6 100644 --- a/app/Http/Controllers/Admin/AirportController.php +++ b/app/Http/Controllers/Admin/AirportController.php @@ -12,9 +12,9 @@ use App\Repositories\AirportRepository; use App\Repositories\Criteria\WhereCriteria; use App\Services\ExportService; use App\Services\ImportService; +use App\Support\Timezonelist; use Flash; use Illuminate\Http\Request; -use Jackiedo\Timezonelist\Facades\Timezonelist; use Log; use Response; use Storage; diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 7499d8bc..e21f53b7 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -14,11 +14,11 @@ use App\Repositories\AirportRepository; use App\Repositories\PirepRepository; use App\Repositories\UserRepository; use App\Services\UserService; +use App\Support\Timezonelist; use DB; use Flash; use Hash; use Illuminate\Http\Request; -use Jackiedo\Timezonelist\Facades\Timezonelist; use Log; use Prettus\Repository\Exceptions\RepositoryException; use Response; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ffa1b2b8..90d22a4d 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -10,12 +10,12 @@ use App\Repositories\AirlineRepository; use App\Repositories\AirportRepository; use App\Services\UserService; use App\Support\Countries; +use App\Support\Timezonelist; use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; -use Jackiedo\Timezonelist\Facades\Timezonelist; /** * Class RegisterController @@ -56,6 +56,8 @@ class RegisterController extends Controller } /** + * @throws \Exception + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showRegistrationForm() diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index 59e67a04..6734c07f 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -9,15 +9,15 @@ use App\Repositories\AirlineRepository; use App\Repositories\AirportRepository; use App\Repositories\UserRepository; use App\Support\Countries; -use Flash; -use Hash; +use App\Support\Timezonelist; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Validator; use Intervention\Image\Facades\Image; -use Jackiedo\Timezonelist\Facades\Timezonelist; -use Log; -use Validator; +use Laracasts\Flash\Flash; /** * Class ProfileController @@ -86,9 +86,10 @@ class ProfileController extends Controller /** * Show the edit for form the user's profile - * * @param Request $request * + * @throws \Exception + * * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function edit(Request $request) diff --git a/app/Providers/TimezonelistProvider.php b/app/Providers/TimezonelistProvider.php deleted file mode 100644 index 6ac0dfff..00000000 --- a/app/Providers/TimezonelistProvider.php +++ /dev/null @@ -1,30 +0,0 @@ -app->singleton('timezonelist', function ($app) { - return new Timezonelist(); - }); - } -} diff --git a/app/Support/Timezonelist.php b/app/Support/Timezonelist.php index 382f92e7..6443d2fa 100644 --- a/app/Support/Timezonelist.php +++ b/app/Support/Timezonelist.php @@ -22,12 +22,14 @@ namespace App\Support; use DateTimeZone; +use Illuminate\Support\Facades\Log; /** * This library is from: * https://github.com/JackieDo/Timezone-List * - * With some changes to suite the formatting, etc that we need + * With some changes to suite the formatting, etc that we need. + * Also changed it to provide all static methods instead of through a facade */ class Timezonelist { @@ -40,7 +42,7 @@ class Timezonelist * * @var array */ - protected $popularTimezones = [ + protected static $popularTimezones = [ 'GMT' => 'GMT timezone', 'UTC' => 'UTC timezone', ]; @@ -49,7 +51,7 @@ class Timezonelist * * @var array */ - protected $continents = [ + protected static $continents = [ 'Africa' => DateTimeZone::AFRICA, 'America' => DateTimeZone::AMERICA, 'Antarctica' => DateTimeZone::ANTARCTICA, @@ -69,14 +71,17 @@ class Timezonelist * @param string $continent * @param bool $htmlencode * - * @throws \Exception - * @throws \Exception - * * @return string */ - protected function formatTimezone($timezone, $continent, $htmlencode = true) + public static function formatTimezone($timezone, $continent, $htmlencode = true) { - $time = new \DateTimeImmutable(null, new DateTimeZone($timezone)); + try { + $time = new \DateTimeImmutable(null, new DateTimeZone($timezone)); + } catch (\Exception $e) { + Log::error($e->getMessage()); + return ''; + } + $offset = $time->format('P'); if ($htmlencode) { $offset = str_replace(['-', '+'], [' − ', ' + '], $offset); @@ -95,9 +100,11 @@ class Timezonelist * @param mixed $attr * @param bool $htmlencode * + * @throws \Exception + * * @return string */ - public function create($name, $selected = '', $attr = '', $htmlencode = true) + public static function create($name, $selected = '', $attr = '', $htmlencode = true) { // Attributes for select element $attrSet = ''; @@ -114,13 +121,13 @@ class Timezonelist $listbox = '