Added native os notifications

This commit is contained in:
2026-07-02 15:57:57 +10:00
parent 027437dc9b
commit 4c98b33fb4
4 changed files with 15 additions and 8 deletions
@@ -32,6 +32,7 @@ class UpdateDepartedFlights extends Command
foreach ($userFlights as $flight) {
$flight->update(['departure_processed_at' => $now]);
$this->notifyFollowersOnDeparture($flight);
}
}
@@ -41,7 +42,10 @@ class UpdateDepartedFlights extends Command
$title = "{$user->name} is taking off!";
$flightNumber = $flight->flight_number ? "On {$flight->flight_number} from" : 'From';
$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) {
$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,
'seat_type' => $flightToReconcile->seat_type !== null ? (int) $flightToReconcile->seat_type : null,
'flight_reason' => $flightToReconcile->flight_reason !== null ? (int) $flightToReconcile->flight_reason : null,
'seat_number' => $flightToReconcile->seat_number ?? '',
'airline_options' => $this->getPossibleAirlines($flightToReconcile->airline ?? ''),
'to_options' => $this->getPossibleAirports($flightToReconcile->to ?? ''),
'from_options' => $this->getPossibleAirports($flightToReconcile->from ?? ''),
@@ -380,7 +381,7 @@ class FlightImportController extends Controller
$handle = fopen($path, 'r');
fgetcsv($handle);
fgetcsv($handle); // skip blank first line
// Read and normalise header row
$headers = array_map(
@@ -389,9 +390,6 @@ class FlightImportController extends Controller
);
\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 = [
'date' => 'date',
@@ -415,6 +413,11 @@ class FlightImportController extends Controller
$imported = 0;
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)) {
continue; // skip malformed rows
}
+1 -1
View File
@@ -45,7 +45,7 @@ class UserFlightPolicy
*/
public function delete(User $user, UserFlight $userFlight): bool
{
return $user->id === $userFlight->user_id;
return ($user->id === $userFlight->user_id) || $user->hasRole('admin');
}
/**
+1
View File
@@ -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-col>
<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-col>
</v-row>