File: /var/www/html/laravel/database/migrations/2024_08_22_075408_extending_notams_table.php
<?php
use App\Models\Notam;
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
{
Schema::table('notams', function (Blueprint $table) {
$table->integer('user_id')->nullable();
$table->string('request_hash')->nullable();
});
$logs = Notam::all();
foreach ($logs as $log) {
$log->request_hash = hash('sha256', $log->input);
$log->save();
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};