Added native os notifications
This commit is contained in:
@@ -32,6 +32,7 @@ class UpdateDepartedFlights extends Command
|
|||||||
|
|
||||||
foreach ($userFlights as $flight) {
|
foreach ($userFlights as $flight) {
|
||||||
$flight->update(['departure_processed_at' => $now]);
|
$flight->update(['departure_processed_at' => $now]);
|
||||||
|
$this->notifyFollowersOnDeparture($flight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,10 @@ class UpdateDepartedFlights extends Command
|
|||||||
$title = "{$user->name} is taking off!";
|
$title = "{$user->name} is taking off!";
|
||||||
$flightNumber = $flight->flight_number ? "On {$flight->flight_number} from" : 'From';
|
$flightNumber = $flight->flight_number ? "On {$flight->flight_number} from" : 'From';
|
||||||
$body = "{$flightNumber} {$flight->departureAirport->municipality} → {$flight->arrivalAirport->municipality}";
|
$body = "{$flightNumber} {$flight->departureAirport->municipality} → {$flight->arrivalAirport->municipality}";
|
||||||
$url = route('profile.flight', [$flight->id]);
|
$url = route('profile.flight', [
|
||||||
|
'user' => $user->id,
|
||||||
|
'userFlight' => $flight->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$user->followers()->get()->each(function (User $follower) use ($title, $body, $url) {
|
$user->followers()->get()->each(function (User $follower) use ($title, $body, $url) {
|
||||||
$notify = $follower->getSetting('notify_on_flight_departure');
|
$notify = $follower->getSetting('notify_on_flight_departure');
|
||||||
@@ -55,7 +59,6 @@ class UpdateDepartedFlights extends Command
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ class FlightImportController extends Controller
|
|||||||
'flight_class' => $flightToReconcile->flight_class !== null ? (int) $flightToReconcile->flight_class : null,
|
'flight_class' => $flightToReconcile->flight_class !== null ? (int) $flightToReconcile->flight_class : null,
|
||||||
'seat_type' => $flightToReconcile->seat_type !== null ? (int) $flightToReconcile->seat_type : null,
|
'seat_type' => $flightToReconcile->seat_type !== null ? (int) $flightToReconcile->seat_type : null,
|
||||||
'flight_reason' => $flightToReconcile->flight_reason !== null ? (int) $flightToReconcile->flight_reason : null,
|
'flight_reason' => $flightToReconcile->flight_reason !== null ? (int) $flightToReconcile->flight_reason : null,
|
||||||
|
'seat_number' => $flightToReconcile->seat_number ?? '',
|
||||||
'airline_options' => $this->getPossibleAirlines($flightToReconcile->airline ?? ''),
|
'airline_options' => $this->getPossibleAirlines($flightToReconcile->airline ?? ''),
|
||||||
'to_options' => $this->getPossibleAirports($flightToReconcile->to ?? ''),
|
'to_options' => $this->getPossibleAirports($flightToReconcile->to ?? ''),
|
||||||
'from_options' => $this->getPossibleAirports($flightToReconcile->from ?? ''),
|
'from_options' => $this->getPossibleAirports($flightToReconcile->from ?? ''),
|
||||||
@@ -380,7 +381,7 @@ class FlightImportController extends Controller
|
|||||||
|
|
||||||
$handle = fopen($path, 'r');
|
$handle = fopen($path, 'r');
|
||||||
|
|
||||||
fgetcsv($handle);
|
fgetcsv($handle); // skip blank first line
|
||||||
|
|
||||||
// Read and normalise header row
|
// Read and normalise header row
|
||||||
$headers = array_map(
|
$headers = array_map(
|
||||||
@@ -389,9 +390,6 @@ class FlightImportController extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
\Log::debug('CSV headers', $headers);
|
\Log::debug('CSV headers', $headers);
|
||||||
$firstRow = fgetcsv($handle);
|
|
||||||
\Log::debug('First row', $firstRow ?? ['empty']);
|
|
||||||
\Log::debug('Header count: ' . count($headers) . ', Row count: ' . count($firstRow ?? []));
|
|
||||||
|
|
||||||
$map = [
|
$map = [
|
||||||
'date' => 'date',
|
'date' => 'date',
|
||||||
@@ -415,6 +413,11 @@ class FlightImportController extends Controller
|
|||||||
$imported = 0;
|
$imported = 0;
|
||||||
|
|
||||||
while (($row = fgetcsv($handle)) !== false) {
|
while (($row = fgetcsv($handle)) !== false) {
|
||||||
|
if ($imported === 0) {
|
||||||
|
\Log::debug('First row', $row);
|
||||||
|
\Log::debug('Header count: ' . count($headers) . ', Row count: ' . count($row));
|
||||||
|
}
|
||||||
|
|
||||||
if (count($row) !== count($headers)) {
|
if (count($row) !== count($headers)) {
|
||||||
continue; // skip malformed rows
|
continue; // skip malformed rows
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class UserFlightPolicy
|
|||||||
*/
|
*/
|
||||||
public function delete(User $user, UserFlight $userFlight): bool
|
public function delete(User $user, UserFlight $userFlight): bool
|
||||||
{
|
{
|
||||||
return $user->id === $userFlight->user_id;
|
return ($user->id === $userFlight->user_id) || $user->hasRole('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ watch(() => form.flight_reason, (val) => console.log('flight_reason changed:', v
|
|||||||
<v-select v-model="form.seat_type" label="Seat Type" :items="flight.seat_types" :error-messages="submitForm.errors.seat_type_id" />
|
<v-select v-model="form.seat_type" label="Seat Type" :items="flight.seat_types" :error-messages="submitForm.errors.seat_type_id" />
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" md="6">
|
<v-col cols="12" md="6">
|
||||||
|
{{console.log(form.flight_reason)}}
|
||||||
<v-select v-model="form.flight_reason" label="Reason" :items="flight.flight_reasons" :error-messages="submitForm.errors.flight_reason_id" />
|
<v-select v-model="form.flight_reason" label="Reason" :items="flight.flight_reasons" :error-messages="submitForm.errors.flight_reason_id" />
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|||||||
Reference in New Issue
Block a user