141 lines
5.0 KiB
PHP
141 lines
5.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\BookingResource\Pages;
|
|
use App\Filament\Resources\BookingResource\RelationManagers;
|
|
use App\Models\Booking;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
|
|
class BookingResource extends Resource
|
|
{
|
|
protected static ?string $model = Booking::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\TextInput::make('uuid')
|
|
->label('UUID')
|
|
->required()
|
|
->maxLength(36),
|
|
Forms\Components\Select::make('ride_id')
|
|
->relationship('ride', 'id')
|
|
->default(null),
|
|
Forms\Components\Select::make('offer_id')
|
|
->relationship('offer', 'title')
|
|
->required(),
|
|
Forms\Components\TextInput::make('ride_recommendation_id')
|
|
->numeric()
|
|
->default(null),
|
|
Forms\Components\TextInput::make('customer_name')
|
|
->maxLength(255)
|
|
->default(null),
|
|
Forms\Components\TextInput::make('customer_email')
|
|
->email()
|
|
->maxLength(255)
|
|
->default(null),
|
|
Forms\Components\TextInput::make('customer_phone')
|
|
->tel()
|
|
->maxLength(255)
|
|
->default(null),
|
|
Forms\Components\TextInput::make('party_size')
|
|
->required()
|
|
->numeric()
|
|
->default(1),
|
|
Forms\Components\DateTimePicker::make('booking_for'),
|
|
Forms\Components\TextInput::make('status')
|
|
->required(),
|
|
Forms\Components\TextInput::make('amount')
|
|
->numeric()
|
|
->default(null),
|
|
Forms\Components\TextInput::make('commission_amount')
|
|
->numeric()
|
|
->default(null),
|
|
Forms\Components\Textarea::make('notes')
|
|
->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('uuid')
|
|
->label('UUID')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('ride.id')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('offer.title')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('ride_recommendation_id')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('customer_name')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('customer_email')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('customer_phone')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('party_size')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('booking_for')
|
|
->dateTime()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('status'),
|
|
Tables\Columns\TextColumn::make('amount')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('commission_amount')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListBookings::route('/'),
|
|
'create' => Pages\CreateBooking::route('/create'),
|
|
'edit' => Pages\EditBooking::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|