schema([ Forms\Components\DatePicker::make('posted_at') ->label('Posted At') ->required() ->default(now()), Forms\Components\TextInput::make('description') ->label('Description'), Forms\Components\Select::make('type') ->label('Type') ->options([ 'expense' => 'Expense', 'income' => 'Income', 'transfer' => 'Transfer', ]) ->required(), Forms\Components\Select::make('method') ->label('Method') ->options([ 'deposit' => 'Deposit', 'withdrawal' => 'Withdrawal', ]) ->required(), Forms\Components\TextInput::make('amount') ->label('Amount') ->money(static function (Forms\Get $get) { $account = $get('account_id'); if ($account) { $account = Account::find($account); if ($account) { return $account->currency_code; } } return 'USD'; }) ->required(), Forms\Components\Select::make('category_id') ->label('Category') ->relationship('category', 'name') ->searchable() ->preload() ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('posted_at') ->label('Date') ->formatStateUsing(static function ($state) { $dateFormat = Localization::firstOrFail()->date_format->value ?? DateFormat::DEFAULT; return Carbon::parse($state)->translatedFormat($dateFormat); }), Tables\Columns\TextColumn::make('description') ->wrap() ->label('Description'), Tables\Columns\TextColumn::make('category.name') ->label('Category') ->html() ->formatStateUsing(function ($state, Transaction $record) { $color = $record->category->color ?? '#000000'; return " {$state}"; }), Tables\Columns\TextColumn::make('amount') ->label('Amount') ->sortable() ->weight(FontWeight::Medium) ->color(static fn (Transaction $record) => $record->type === 'expense' ? 'danger' : null) ->currency(static fn (Transaction $record) => $record->account->currency_code, 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\ListTransactions::route('/'), 'create' => Pages\CreateTransaction::route('/create'), 'edit' => Pages\EditTransaction::route('/{record}/edit'), ]; } }