Add all files
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ContactPage\Admin\Resources;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Paymenter\Extensions\Others\ContactPage\Models\ContactMessage;
|
||||
use Paymenter\Extensions\Others\ContactPage\Admin\Resources\ContactMessageResource\Pages;
|
||||
|
||||
class ContactMessageResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ContactMessage::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'ri-contacts-book-2-line';
|
||||
protected static ?string $navigationGroup = 'Contact Management';
|
||||
protected static ?string $navigationLabel = 'Contact Messages';
|
||||
protected static ?string $pluralLabel = 'Contact Messages';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\TextInput::make('subject')
|
||||
->label('Subject')
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Textarea::make('message')
|
||||
->label('Message')
|
||||
->required()
|
||||
->rows(5)
|
||||
->maxLength(2000)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'unread' => 'Unread',
|
||||
'read' => 'Read',
|
||||
'replied' => 'Replied',
|
||||
'archived' => 'Archived',
|
||||
])
|
||||
->default('unread')
|
||||
->required(),
|
||||
|
||||
Forms\Components\Textarea::make('admin_notes')
|
||||
->label('Admin Notes')
|
||||
->rows(3)
|
||||
->maxLength(1000),
|
||||
|
||||
Forms\Components\DateTimePicker::make('read_at')
|
||||
->label('Read At'),
|
||||
|
||||
Forms\Components\DateTimePicker::make('replied_at')
|
||||
->label('Replied At'),
|
||||
|
||||
Forms\Components\TextInput::make('ip_address')
|
||||
->label('IP Address')
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Textarea::make('user_agent')
|
||||
->label('User Agent')
|
||||
->rows(2)
|
||||
->disabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('subject')
|
||||
->searchable()
|
||||
->limit(50),
|
||||
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->colors([
|
||||
'danger' => 'unread',
|
||||
'warning' => 'read',
|
||||
'success' => 'replied',
|
||||
'gray' => 'archived',
|
||||
]),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Submitted')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('read_at')
|
||||
->label('Read')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('status')
|
||||
->options([
|
||||
'unread' => 'Unread',
|
||||
'read' => 'Read',
|
||||
'replied' => 'Replied',
|
||||
'archived' => 'Archived',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListContactMessages::route('/'),
|
||||
'edit' => Pages\EditContactMessage::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getModel()::where('status', 'unread')->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user