count(); } public static function infolist(Schema $schema): Schema { return $schema ->schema([ Section::make('Informasi Pengirim') ->schema([ Grid::make(4) ->schema([ TextEntry::make('name') ->label('Nama'), TextEntry::make('email') ->label('Email'), TextEntry::make('subject') ->label('Subyek'), TextEntry::make('created_at') ->label('Diterima pada') ->date('l, d F Y H:i'), ]), ]) ->columnSpanFull(), Section::make('Pesan') ->schema([ TextEntry::make('message') ->label('Isi Pesan') ->columnSpanFull(), ]) ->columnSpanFull(), Section::make('Balasan') ->schema([ TextEntry::make('repliedBy.name') ->label('Dibalas Oleh') ->placeholder('Belum dibalas'), TextEntry::make('replied_at') ->label('Dibalas pada') ->date('l, d F Y H:i') ->placeholder('Belum dibalas'), TextEntry::make('reply_message') ->label('Pesan Balasan') ->placeholder('Belum dibalas'), ]) ->columnSpanFull() ->visible(fn (Contact $record): bool => $record->replied_at !== null), ]) ->columns(2); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name') ->label('Nama') ->searchable(), TextColumn::make('email') ->label('Email') ->searchable(), TextColumn::make('subject') ->label('Subyek') ->limit(30), IconColumn::make('replied_at') ->label('Dibalas') ->boolean() ->getStateUsing(fn (Contact $record): bool => $record->replied_at !== null), TextColumn::make('repliedBy.name') ->label('Dibalas Oleh') ->badge() ->placeholder('Belum dibalas') ->sortable(), TextColumn::make('created_at') ->label('Diterima pada') ->date('l, d F Y H:i') ->sortable(), ]) ->filters([ TernaryFilter::make('replied_at') ->label('Status Balasan') ->placeholder('Semua Pesan') ->trueLabel('Sudah Dibalas') ->falseLabel('Belum Dibalas') ->queries( true: fn ($query) => $query->whereNotNull('replied_at'), false: fn ($query) => $query->whereNull('replied_at'), ) ->native(false), ]) ->recordActions([ ViewAction::make() ->label('Lihat'), ReplyAction::make('reply'), DeleteAction::make() ->label('Hapus'), ]) ->toolbarActions([ BulkActionGroup::make([ ...DefaultBulkActions::make('Kontak'), ]), ]) ->emptyStateIcon(Heroicon::Envelope) ->emptyStateDescription('Belum ada kontak atau pesan masuk.') ->defaultSort('created_at', 'desc') ->deferFilters(false); } public static function getPages(): array { return [ 'index' => ManageContacts::route('/'), ]; } }