show dates/times in user's timezone
This commit is contained in:
@@ -18,9 +18,10 @@ users:
|
||||
rank_id: 1
|
||||
home_airport_id: KAUS
|
||||
curr_airport_id: KJFK
|
||||
last_pirep_id: pirepid_3
|
||||
flights: 3
|
||||
flight_time: 43200
|
||||
last_pirep_id: pirepid_3
|
||||
timezone: America/Chicago
|
||||
state: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
@@ -197,6 +198,8 @@ flights:
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
dpt_time: 6PM CST
|
||||
arr_time: 11PM EST
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: flightid_2
|
||||
airline_id: 1
|
||||
flight_number: 101
|
||||
@@ -205,6 +208,8 @@ flights:
|
||||
dpt_time: 9AM EST
|
||||
arr_time: 12PM CST
|
||||
route: KJFK KAUS
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: flightid_3
|
||||
airline_id: 1
|
||||
flight_number: 200
|
||||
@@ -213,6 +218,8 @@ flights:
|
||||
dpt_time: 9AM EST
|
||||
arr_time: 12PM CST
|
||||
route: KJFK KAUS
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: flightid_4
|
||||
airline_id: 1
|
||||
flight_number: 201
|
||||
@@ -221,6 +228,8 @@ flights:
|
||||
dpt_time: 10AM EST
|
||||
arr_time: 1PM CST
|
||||
route: KJFK KAUS
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: flightid_5
|
||||
airline_id: 1
|
||||
flight_number: 202
|
||||
@@ -340,6 +349,8 @@ pireps:
|
||||
state: 0
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: pirepid_2
|
||||
user_id: 1
|
||||
airline_id: 1
|
||||
@@ -351,6 +362,8 @@ pireps:
|
||||
state: 0
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: pirepid_3
|
||||
user_id: 1
|
||||
airline_id: 1
|
||||
@@ -362,6 +375,8 @@ pireps:
|
||||
state: 0
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
|
||||
pirep_fields:
|
||||
- id: 1
|
||||
|
||||
@@ -4,9 +4,10 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Log;
|
||||
use Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Facades\Utils;
|
||||
@@ -53,6 +54,7 @@ class RegisterController extends Controller
|
||||
return $this->view('auth.register', [
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class DatabaseService extends BaseService
|
||||
|
||||
# if any time fields are == to "now", then insert the right time
|
||||
foreach($this->time_fields as $tf) {
|
||||
if(array_key_exists($tf, $row) && $row[$tf] === 'now') {
|
||||
if(array_key_exists($tf, $row) && strtolower($row[$tf]) === 'now') {
|
||||
$row[$tf] = $this->time();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,13 +178,26 @@ class GeoService extends BaseService
|
||||
* @param Pirep $pirep
|
||||
* @return array
|
||||
*/
|
||||
public function pirepGeoJson(Pirep $pirep)
|
||||
public function pirepGeoJson($pirep)
|
||||
{
|
||||
$coords = [];
|
||||
$coords[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat];
|
||||
|
||||
// TODO: Add markers for the start/end airports
|
||||
// TODO: Read from the ACARS data table
|
||||
|
||||
// TODO: Check if there's data in the ACARS table
|
||||
if (!empty($pirep->route)) {
|
||||
$route_coords = $this->getCoordsFromRoute(
|
||||
$pirep->dpt_airport->icao,
|
||||
$pirep->arr_airport->icao,
|
||||
[$pirep->dpt_airport->lat, $pirep->dpt_airport->lon],
|
||||
$pirep->route);
|
||||
|
||||
// lat, lon needs to be reversed for GeoJSON
|
||||
foreach ($route_coords as $rc) {
|
||||
$coords[] = [$rc[1], $rc[0]];
|
||||
}
|
||||
}
|
||||
|
||||
$coords[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat];
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
/**
|
||||
* Shortcut for retrieving a setting value
|
||||
*/
|
||||
if (!function_exists('setting')) {
|
||||
if (!function_exists('setting'))
|
||||
{
|
||||
function setting($key, $value = null)
|
||||
{
|
||||
$settingRepo = app('setting'); // defined in AppServiceProvider
|
||||
@@ -19,7 +20,8 @@ if (!function_exists('setting')) {
|
||||
* Wrap the asset URL in the publicBaseUrl that's been
|
||||
* set
|
||||
*/
|
||||
if (!function_exists('public_asset')) {
|
||||
if (!function_exists('public_asset'))
|
||||
{
|
||||
function public_asset($path, $parameters = [], $secure = null)
|
||||
{
|
||||
$publicBaseUrl = app()->publicUrlPath();
|
||||
@@ -32,3 +34,46 @@ if (!function_exists('public_asset')) {
|
||||
return url($path, $parameters, $secure);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a date/time in the proper timezone for a user
|
||||
*/
|
||||
if(!function_exists('show_datetime'))
|
||||
{
|
||||
/**
|
||||
* Format the a Carbon date into the datetime string
|
||||
* but convert it into the user's timezone
|
||||
* @param \Carbon\Carbon $date
|
||||
* @return string
|
||||
*/
|
||||
function show_datetime(\Carbon\Carbon $date)
|
||||
{
|
||||
$timezone = 'UTC';
|
||||
if (Auth::check()) {
|
||||
$timezone = Auth::user()->timezone ?: $timezone;
|
||||
}
|
||||
|
||||
return $date->timezone($timezone)->toDayDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a date/time in the proper timezone for a user
|
||||
*/
|
||||
if (!function_exists('show_date')) {
|
||||
/**
|
||||
* Format the a Carbon date into the datetime string
|
||||
* but convert it into the user's timezone
|
||||
* @param \Carbon\Carbon $date
|
||||
* @return string
|
||||
*/
|
||||
function show_date(\Carbon\Carbon $date)
|
||||
{
|
||||
$timezone = 'UTC';
|
||||
if (Auth::check()) {
|
||||
$timezone = Auth::user()->timezone ?: $timezone;
|
||||
}
|
||||
|
||||
return $date->timezone($timezone)->toFormattedDateString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user