Add Routing module: EvRoute, pricing, time slots, read API, caching (T3.1-T3.7)

Implements Phase 3 in full: EvRoute model with company/destination relations
and a from/to-must-differ guard; the ev_route_time_slots pivot; RoutePricing
with a per-route is_blocked flag (every route auto-manages exactly one price
row per vehicle option via a fixed-row Filament repeater on both create and
edit); PricingService::quote() with a shared VehicleOption enum; RoutingPlugin
with the EvRouteResource admin UI (activation gated on non-blocked options
being priced); the /api/v1/routes read API (list/show/pricing/time-slots,
AI-agent-friendly nested shape); and Redis-tag-based response caching
invalidated via EvRoute/RoutePricing observers.
This commit is contained in:
Nyan Lin Paing
2026-08-06 23:49:42 +07:00
parent 7872105f2f
commit 4da9ecfe7d
38 changed files with 1588 additions and 2 deletions
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ev_routes', function (Blueprint $table) {
$table->id();
$table->foreignId('ev_company_id')->constrained('ev_companies')->cascadeOnDelete();
$table->foreignId('from_destination_id')->constrained('destinations')->cascadeOnDelete();
$table->foreignId('to_destination_id')->constrained('destinations')->cascadeOnDelete();
$table->boolean('is_round_trip')->default(false);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ev_routes');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ev_route_time_slots', function (Blueprint $table) {
$table->id();
$table->foreignId('ev_route_id')->constrained('ev_routes')->cascadeOnDelete();
$table->foreignId('departure_time_slot_id')->constrained('departure_time_slots')->cascadeOnDelete();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->unique(['ev_route_id', 'departure_time_slot_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ev_route_time_slots');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('route_pricing', function (Blueprint $table) {
$table->id();
$table->foreignId('ev_route_id')->constrained('ev_routes')->cascadeOnDelete();
$table->string('vehicle_option');
$table->decimal('price', 10, 2);
$table->timestamps();
$table->unique(['ev_route_id', 'vehicle_option']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('route_pricing');
}
};
@@ -0,0 +1,28 @@
<?php
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('route_pricing', function (Blueprint $table) {
$table->boolean('is_blocked')->default(false)->after('price');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('route_pricing', function (Blueprint $table) {
$table->dropColumn('is_blocked');
});
}
};