Added Notifications

This commit is contained in:
2026-05-18 14:51:46 +10:00
parent 10b5b6a5c9
commit e1bed676e4
5 changed files with 67 additions and 5 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Models\UserAction;
use App\Models\UserFlight;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('app:flight-feed-update')]
#[Description('Command description')]
class FlightFeedUpdate extends Command
{
public function handle()
{
$time = now('UTC');
$this->logFlightActions('flight_departing', UserFlight::where('departure_date', $time)->get()->toArray());
$this->logFlightActions('flight_arriving', UserFlight::where('arrival_date', $time)->get()->toArray());
}
/**
* @param string $type
* @param UserFlight[] $flights
* @return void
*/
private function logFlightActions(string $type, array $flights): void
{
foreach ($flights as $flight) {
UserAction::create([
'user_id' => $flight->user_id,
'type' => $type,
'data' => $flight->snapshot($flight->id),
]);
}
}
}