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:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Routing\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Modules\Catalog\Models\Destination;
|
||||
use Modules\Catalog\Models\EvCompany;
|
||||
use Modules\Routing\Models\EvRoute;
|
||||
|
||||
/**
|
||||
* @extends Factory<EvRoute>
|
||||
*/
|
||||
class EvRouteFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'ev_company_id' => EvCompany::factory(),
|
||||
'from_destination_id' => Destination::factory(),
|
||||
'to_destination_id' => Destination::factory(),
|
||||
'is_round_trip' => false,
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Routing\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Modules\Routing\Models\EvRoute;
|
||||
use Modules\Routing\Models\RoutePricing;
|
||||
use Modules\Shared\Enums\VehicleOption;
|
||||
|
||||
/**
|
||||
* @extends Factory<RoutePricing>
|
||||
*/
|
||||
class RoutePricingFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'ev_route_id' => EvRoute::factory(),
|
||||
'vehicle_option' => fake()->randomElement(VehicleOption::cases()),
|
||||
'price' => fake()->randomFloat(2, 5000, 50000),
|
||||
'is_blocked' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user