value; protected static ?int $navigationSort = 4; protected static ?string $modelLabel = 'Hợp đồng'; protected static ?string $pluralModelLabel = 'Hợp đồng'; public static function form(Schema $schema): Schema { return ContractForm::configure($schema); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('contract_number')->label('Số HĐ')->searchable(), Tables\Columns\TextColumn::make('product.code')->label('Sản phẩm'), Tables\Columns\TextColumn::make('total_value')->label('Giá trị')->money('VND'), Tables\Columns\TextColumn::make('paid_amount')->label('Đã thu')->money('VND'), Tables\Columns\TextColumn::make('remaining_amount')->label('Còn lại')->money('VND'), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\Action::make('generateSchedule') ->label('Tạo lịch TT') ->icon('heroicon-o-calendar-days') ->color('warning') ->requiresConfirmation() ->modalHeading('Tạo lịch thanh toán') ->modalDescription('Hành động này sẽ xóa lịch thanh toán cũ (nếu có) và tạo lại từ mẫu của dự án.') ->action(function (Contract $record) { try { ContractScheduleService::generateFromTemplate($record); } catch (\InvalidArgumentException $e) { // Filament sẽ tự động hiển thị lỗi nếu throw ra trong action throw $e; } }) ->visible(fn (Contract $record) => $record->signing_date !== null), ]); } public static function getRelations(): array { return [ScheduleItemsRelationManager::class]; } public static function getPages(): array { return [ 'index' => Pages\ListContracts::route('/'), 'create' => Pages\CreateContract::route('/create'), 'edit' => Pages\EditContract::route('/{record}/edit'), ]; } }