File: /var/www/html/laravel/database/migrations/2026_03_02_081509_update_notam_gpt_requests.php
<?php
use App\Models\Notam;
use App\Models\NotamGptRequest;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$notamGptRequests = NotamGptRequest::query()
->whereNull('is_valid')
->get();
foreach ($notamGptRequests as $notamGptRequest) {
echo "Processing {$notamGptRequest->id}\n";
$notam = new Notam();
$validationErrors = $notam->validateDataFormat($notamGptRequest->output);
if (!count($validationErrors)
|| (count($validationErrors) == 1 && substr_count($validationErrors[0], 'CheckNeeded'))) {
$notamGptRequest->is_valid = 1;
} else {
$notamGptRequest->is_valid = 0;
}
$notamGptRequest->save();
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
}
};