components([ Schemas\Components\Section::make('Detalii') ->columns(2) ->schema([ Forms\Components\Select::make('client_id') ->label('Client') ->options(fn () => Client::pluck('name', 'id')) ->searchable() ->required(), Forms\Components\Select::make('vehicle_id') ->label('Auto') ->options(fn (Schemas\Components\Utilities\Get $get) => $get('client_id') ? Vehicle::where('client_id', $get('client_id'))->pluck('plate', 'id') : []) ->searchable(), Forms\Components\TextInput::make('name')->label('Subiect')->required()->maxLength(160), Forms\Components\TextInput::make('price')->label('Valoare')->numeric()->default(0), Forms\Components\Select::make('stage') ->options(Deal::STAGES) ->default('new') ->required(), Forms\Components\Select::make('source') ->options(Lead::SOURCES) ->searchable(), Forms\Components\Select::make('assigned_to') ->label('Responsabil') ->options(fn () => User::pluck('name', 'id')) ->searchable(), ]), Forms\Components\Textarea::make('note')->label('Notițe')->columnSpanFull()->rows(3), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('id')->label('#')->sortable(), Tables\Columns\TextColumn::make('name')->label('Subiect')->searchable()->limit(40), Tables\Columns\TextColumn::make('client.name')->label('Client')->searchable(), Tables\Columns\TextColumn::make('vehicle.plate')->label('Auto')->placeholder('—'), Tables\Columns\TextColumn::make('stage') ->formatStateUsing(fn ($state) => Deal::STAGES[$state] ?? $state) ->badge() ->colors([ 'gray' => ['new'], 'info' => ['contact', 'agree'], 'warning' => ['scheduled', 'arrived', 'in_work'], 'success' => ['done'], 'danger' => ['lost'], ]), Tables\Columns\TextColumn::make('price')->money('MDL')->sortable(), Tables\Columns\TextColumn::make('source')->label('Sursă')->formatStateUsing(fn ($state) => Lead::SOURCES[$state] ?? $state)->placeholder('—'), Tables\Columns\TextColumn::make('assignedTo.name')->label('Responsabil')->placeholder('—'), Tables\Columns\TextColumn::make('created_at')->date()->sortable(), ]) ->filters([ Tables\Filters\SelectFilter::make('stage')->options(Deal::STAGES), Tables\Filters\SelectFilter::make('assigned_to') ->label('Responsabil') ->options(fn () => User::pluck('name', 'id')), ]) ->actions([ Actions\EditAction::make(), Actions\DeleteAction::make(), ]) ->defaultSort('created_at', 'desc'); } public static function getPages(): array { return [ 'index' => Pages\ListDeals::route('/'), 'create' => Pages\CreateDeal::route('/create'), 'edit' => Pages\EditDeal::route('/{record}/edit'), ]; } }