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
@@ -6,6 +6,8 @@ use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Modules\Shared\Enums\VehicleOption;
@@ -15,74 +17,88 @@ class EvRouteForm
{
return $schema
->components([
Select::make('ev_company_id')
->label('EV Company')
->relationship('company', 'name')
->required()
->searchable()
->preload(),
Select::make('from_destination_id')
->label('From')
->relationship('fromDestination', 'name')
->required()
->searchable()
->preload(),
Select::make('to_destination_id')
->label('To')
->relationship('toDestination', 'name')
->required()
->searchable()
->preload()
->different('from_destination_id')
->validationMessages([
'different' => 'The destination must be different from the origin.',
]),
Select::make('timeSlots')
->label('Departure Time Slots')
->relationship('timeSlots', 'label')
->multiple()
->searchable()
->preload(),
Toggle::make('is_round_trip')
->required()
->default(false),
Toggle::make('is_active')
->required()
->default(false)
->helperText('Every non-blocked vehicle option must have a price above 0 before a route can be activated.'),
Repeater::make('pricing')
->relationship()
->label('Pricing')
Section::make('Route')
->schema([
Select::make('vehicle_option')
->options(array_combine(
array_map(fn (VehicleOption $option) => $option->value, VehicleOption::cases()),
array_map(fn (VehicleOption $option) => str($option->value)->headline()->toString(), VehicleOption::cases()),
))
->disabled()
->dehydrated()
->required(),
TextInput::make('price')
->numeric()
->minValue(0)
->required(),
Toggle::make('is_blocked')
->label('Blocked')
->helperText('Hidden from booking regardless of price.'),
Grid::make(2)
->schema([
Select::make('ev_company_id')
->label('EV Company')
->relationship('company', 'name')
->required()
->searchable()
->preload(),
Select::make('from_destination_id')
->label('From')
->relationship('fromDestination', 'name')
->required()
->searchable()
->preload(),
Select::make('to_destination_id')
->label('To')
->relationship('toDestination', 'name')
->required()
->searchable()
->preload()
->different('from_destination_id')
->validationMessages([
'different' => 'The destination must be different from the origin.',
]),
Select::make('timeSlots')
->label('Departure Time Slots')
->relationship('timeSlots', 'label')
->multiple()
->searchable()
->preload(),
]),
])
->columns(3)
->default(
collect(VehicleOption::cases())
->map(fn (VehicleOption $option) => [
'vehicle_option' => $option->value,
'price' => 0,
'is_blocked' => false,
->columnSpanFull(),
Section::make('Options')
->schema([
Grid::make(2)
->schema([
Toggle::make('is_active')
->required()
->default(false)
->helperText('Every non-blocked vehicle option must have a price above 0 before a route can be activated.'),
]),
])
->columnSpanFull(),
Section::make('Pricing')
->schema([
Repeater::make('pricing')
->relationship()
->hiddenLabel()
->schema([
Select::make('vehicle_option')
->options(array_combine(
array_map(fn (VehicleOption $option) => $option->value, VehicleOption::cases()),
array_map(fn (VehicleOption $option) => str($option->value)->headline()->toString(), VehicleOption::cases()),
))
->disabled()
->dehydrated()
->required(),
TextInput::make('price')
->numeric()
->minValue(0)
->required(),
Toggle::make('is_blocked')
->label('Blocked')
->helperText('Hidden from booking regardless of price.'),
])
->all()
)
->addable(false)
->deletable(false)
->reorderable(false)
->columns(3)
->default(
collect(VehicleOption::cases())
->map(fn (VehicleOption $option) => [
'vehicle_option' => $option->value,
'price' => 0,
'is_blocked' => false,
])
->all()
)
->addable(false)
->deletable(false)
->reorderable(false),
])
->columnSpanFull(),
]);
}
@@ -5,8 +5,10 @@ namespace Modules\Routing\Filament\Resources\EvRoutes\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Support\Enums\Width;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Modules\Routing\Models\EvRoute;
@@ -40,8 +42,6 @@ class EvRoutesTable
.($pricing->is_blocked ? 'Blocked' : number_format($pricing->price, 0)))
->all())
->listWithLineBreaks(),
IconColumn::make('is_round_trip')
->boolean(),
IconColumn::make('is_active')
->boolean(),
TextColumn::make('created_at')
@@ -50,9 +50,25 @@ class EvRoutesTable
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
SelectFilter::make('ev_company_id')
->label('Company')
->relationship('company', 'name')
->searchable()
->preload(),
SelectFilter::make('from_destination_id')
->label('From')
->relationship('fromDestination', 'name')
->searchable()
->preload(),
SelectFilter::make('to_destination_id')
->label('To')
->relationship('toDestination', 'name')
->searchable()
->preload(),
TernaryFilter::make('is_active'),
TernaryFilter::make('is_round_trip'),
])
->filtersFormColumns(2)
->filtersFormWidth(Width::Large)
->recordActions([
EditAction::make(),
])