Add all files
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<?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\AbuseReport;
|
||||
use Paymenter\Extensions\Others\ContactPage\Admin\Resources\AbuseReportResource\Pages;
|
||||
|
||||
class AbuseReportResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AbuseReport::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'ri-police-badge-line';
|
||||
protected static ?string $navigationGroup = 'Contact Management';
|
||||
protected static ?string $navigationLabel = 'Abuse Reports';
|
||||
protected static ?string $pluralLabel = 'Abuse Reports';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('reporter_name')
|
||||
->label('Reporter Name')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\TextInput::make('reporter_email')
|
||||
->label('Reporter Email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Select::make('abuse_type')
|
||||
->label('Abuse Type')
|
||||
->options(AbuseReport::getAbuseTypes())
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('reported_url')
|
||||
->label('Reported URL')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\TextInput::make('reported_user')
|
||||
->label('Reported Email')
|
||||
->maxLength(255)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Textarea::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->rows(5)
|
||||
->maxLength(2000)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Textarea::make('evidence')
|
||||
->label('Evidence')
|
||||
->rows(3)
|
||||
->maxLength(1000)
|
||||
->disabled(),
|
||||
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'pending' => 'Pending',
|
||||
'investigating' => 'Investigating',
|
||||
'resolved' => 'Resolved',
|
||||
'dismissed' => 'Dismissed',
|
||||
])
|
||||
->default('pending')
|
||||
->required(),
|
||||
|
||||
Forms\Components\Textarea::make('admin_notes')
|
||||
->label('Admin Notes')
|
||||
->rows(3)
|
||||
->maxLength(1000),
|
||||
|
||||
Forms\Components\DateTimePicker::make('investigated_at')
|
||||
->label('Investigated At'),
|
||||
|
||||
Forms\Components\DateTimePicker::make('resolved_at')
|
||||
->label('Resolved 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('reporter_name')
|
||||
->label('Reporter')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('reporter_email')
|
||||
->label('Email')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\BadgeColumn::make('abuse_type')
|
||||
->label('Type')
|
||||
->formatStateUsing(fn (string $state): string => AbuseReport::getAbuseTypes()[$state] ?? $state)
|
||||
->colors([
|
||||
'danger' => ['spam', 'harassment'],
|
||||
'warning' => ['copyright', 'phishing'],
|
||||
'gray' => ['other'],
|
||||
]),
|
||||
|
||||
Tables\Columns\TextColumn::make('reported_url')
|
||||
->label('URL')
|
||||
->limit(30)
|
||||
->tooltip(fn ($state) => strlen($state) > 30 ? $state : null),
|
||||
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->colors([
|
||||
'danger' => 'pending',
|
||||
'warning' => 'investigating',
|
||||
'success' => 'resolved',
|
||||
'gray' => 'dismissed',
|
||||
]),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Reported')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('resolved_at')
|
||||
->label('Resolved')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('status')
|
||||
->options([
|
||||
'pending' => 'Pending',
|
||||
'investigating' => 'Investigating',
|
||||
'resolved' => 'Resolved',
|
||||
'dismissed' => 'Dismissed',
|
||||
]),
|
||||
Tables\Filters\SelectFilter::make('abuse_type')
|
||||
->label('Abuse Type')
|
||||
->options(AbuseReport::getAbuseTypes()),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAbuseReports::route('/'),
|
||||
'edit' => Pages\EditAbuseReport::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getModel()::where('status', 'pending')->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user