Files
FlightsAPI/app/Console/Commands/UpdateDepartedFlights.php
T

41 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\Aircraft;
use App\Models\Notification;
use App\Models\UserFlight;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
#[Signature('app:update-departed-flights')]
#[Description('Command description')]
class UpdateDepartedFlights extends Command
{
/**
* Execute the console command.
*/
public function handle(): void
{
$now = now()->utc();
$now = now()->utc();
$userFlights = UserFlight::where('departure_date', '<=', $now->toDateTimeString())
->where('departure_date', '>', $now->copy()->subMinute()->toDateTimeString())
->get();
$this->info("Found {$userFlights->count()} flights.");
foreach ($userFlights as $flight) {
$flight->touch();
}
$this->info("Touching flight {$flight->id}");
$result = $flight->touch();
$this->info("Touch result: " . var_export($result, true));
}
}