show dates/times in user's timezone
This commit is contained in:
parent
eb6e624a4d
commit
3b8621371a
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ return [
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
'version' => '7.0',
|
||||
|
||||
# DON'T CHANGE THIS OR ELSE YOUR TIMES WILL BE MESSED UP!
|
||||
'timezone' => 'UTC',
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-6">
|
||||
<div>
|
||||
<span class="description">DEP </span>
|
||||
{!! $pirep->dpt_airport->icao !!}
|
||||
@ -41,13 +41,10 @@
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">File Date </span>
|
||||
{!! $pirep->created_at !!}
|
||||
{!! show_datetime($pirep->created_at) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-6">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,6 +2,7 @@
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Registered</th>
|
||||
<th class="text-center">Active</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
@ -10,6 +11,7 @@
|
||||
<tr>
|
||||
<td>{!! $user->name !!}</td>
|
||||
<td>{!! $user->email !!}</td>
|
||||
<td>{!! show_date($user->created_at) !!}</td>
|
||||
<td class="text-center">
|
||||
@if($user->state == PilotState::ACTIVE)
|
||||
<span class="label label-success">
|
||||
|
@ -42,6 +42,14 @@
|
||||
<p class="text-danger">{{ $errors->first('home_airport_id') }}</p>
|
||||
@endif
|
||||
|
||||
<label for="timezone" class="control-label">Timezone</label>
|
||||
<div class="input-group form-group-no-border{{ $errors->has('timezone') ? ' has-danger' : '' }}">
|
||||
{!! Form::select('timezone', $timezones, null, ['id'=>'timezone', 'class' => 'form-control select2' ]); !!}
|
||||
</div>
|
||||
@if ($errors->has('timezone'))
|
||||
<p class="text-danger">{{ $errors->first('timezone') }}</p>
|
||||
@endif
|
||||
|
||||
<label for="password" class="control-label">Password</label>
|
||||
<div class="input-group form-group-no-border{{ $errors->has('password') ? ' has-danger' : '' }}">
|
||||
{!! Form::password('password', ['class' => 'form-control']) !!}
|
||||
|
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-6">
|
||||
<div>
|
||||
<span class="description">DEP </span>
|
||||
{!! $pirep->dpt_airport->icao !!}
|
||||
@ -42,15 +42,12 @@
|
||||
{!! $pirep->level !!}
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">File Date </span>
|
||||
{!! $pirep->created_at !!}
|
||||
<span class="description">Filed On: </span>
|
||||
{!! show_datetime($pirep->created_at) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
<div class="col-sm-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -44,7 +44,7 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Route</td>
|
||||
<td>Filed Route</td>
|
||||
<td>
|
||||
{!! $pirep->route !!}
|
||||
</td>
|
||||
@ -57,6 +57,13 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Filed On</td>
|
||||
<td>
|
||||
{!! show_datetime($pirep->created_at) !!}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user