schema([ Forms\Components\TextInput::make('currency_code') ->label('ارز') ->disabled(), Forms\Components\TextInput::make('amount') ->label('مبلغ کل') ->disabled(), Forms\Components\TextInput::make('settled_amount') ->label('تسویه‌شده') ->disabled(), ]); } public function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('currency_code') ->label('ارز') ->badge() ->color('info'), Tables\Columns\TextColumn::make('amount') ->label('مبلغ کل') ->numeric(2) ->sortable(), Tables\Columns\TextColumn::make('settled_amount') ->label('تسویه‌شده') ->numeric(2) ->color('success'), Tables\Columns\TextColumn::make('balance') ->label('مانده') ->numeric(2) ->badge() ->color(fn ($record) => $record->balance > 0 ? 'danger' : 'gray'), Tables\Columns\TextColumn::make('status') ->label('وضعیت') ->badge() ->formatStateUsing(fn (string $state) => match ($state) { 'open' => 'باز', 'partially_settled' => 'نیمه‌تسویه', 'settled' => 'تسویه‌شده', default => $state, }) ->color(fn (string $state) => match ($state) { 'open' => 'danger', 'partially_settled' => 'warning', 'settled' => 'success', default => 'gray', }), Tables\Columns\TextColumn::make('reason') ->label('دلیل') ->limit(40) ->toggleable(), Tables\Columns\TextColumn::make('granted_at') ->label('تاریخ اعطا') ->dateTime('Y/m/d') ->sortable(), ]) ->filters([ Tables\Filters\SelectFilter::make('status') ->label('وضعیت') ->options([ 'open' => 'باز', 'partially_settled' => 'نیمه‌تسویه', 'settled' => 'تسویه‌شده', ]), Tables\Filters\SelectFilter::make('currency_code') ->label('ارز') ->options(fn () => CustomerCredit::select('currency_code') ->distinct() ->orderBy('currency_code') ->pluck('currency_code', 'currency_code') ->toArray()), ]) ->headerActions([ // ایجاد اعتبار فقط از طریق CustomerCreditResource (با Policy) Tables\Actions\Action::make('manage_credits') ->label('مدیریت اعتبارها') ->icon('heroicon-o-arrow-left') ->url(fn () => route('filament.admin.resources.customer-credits.index')) ->color('primary'), ]) ->actions([ Tables\Actions\ViewAction::make(), ]) ->defaultSort('created_at', 'desc'); } }