add notes/remark and refactor round-trip
PHP Tests / php-tests (push) Has been cancelled

This commit is contained in:
Nyan Lin Paing
2026-08-22 21:43:41 +07:00
parent 894352b43f
commit fa908cdcaf
46 changed files with 1679 additions and 182 deletions
@@ -29,6 +29,8 @@ class BookingFactory extends Factory
'user_id' => null,
'openid' => null,
'ev_route_id' => EvRoute::factory(),
'linked_booking_id' => null,
'is_return_leg' => false,
'departure_time_slot_id' => DepartureTimeSlot::factory(),
'travel_date' => now()->addDay()->toDateString(),
'passenger_name' => $this->faker->name(),
@@ -41,8 +43,6 @@ class BookingFactory extends Factory
'dropoff_lng' => null,
'price' => $this->faker->randomFloat(2, 5000, 50000),
'status' => BookingStatus::PendingPayment,
'is_round_trip' => false,
'return_travel_date' => null,
'created_by_channel' => BookingChannel::MiniApp,
'driver_name' => null,
'driver_phone' => null,
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 'notes' customer-supplied, submitted via the booking create API
* endpoint (StoreBookingRequest). 'remark' staff-only, set from the
* admin panel (SetRemarkTableAction); never exposed on the customer
* BookingResource. Both nullable, free text.
*/
public function up(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->text('notes')->nullable();
$table->text('remark')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropColumn(['notes', 'remark']);
});
}
};
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Round trip is redesigned as two linked one-way Booking rows (outbound
* + return) rather than a flag + a lone return date on a single row
* the return leg needs its own route/time-slot/price/driver-vehicle
* assignment, since it may run with a different vehicle than the
* outbound leg (domain.md §2b). `is_round_trip` becomes a computed
* accessor on the model (`linked_booking_id !== null`), so the column
* is dropped rather than kept redundant.
*/
public function up(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropColumn(['is_round_trip', 'return_travel_date']);
$table->foreignId('linked_booking_id')->nullable()->after('ev_route_id')
->constrained('bookings')->nullOnDelete();
$table->boolean('is_return_leg')->default(false)->after('linked_booking_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropConstrainedForeignId('linked_booking_id');
$table->dropColumn('is_return_leg');
$table->boolean('is_round_trip')->default(false);
$table->date('return_travel_date')->nullable();
});
}
};