chore: update composer dependencies to include phppresentation chore: update composer.lock after adding phppresentation feat: create categories migration for category management feat: create templates migration for template storage feat: create template generations migration for tracking template usage feat: create template keys migration for template customization feat: create notifications migration for user notifications feat: update API routes for categories, templates, and user profile management docs: update API documentation to include new endpoints for profile and wallet
70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Notifications\Tables;
|
|
|
|
use App\Enums\NotificationType;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class NotificationsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('user.name')
|
|
->label('کاربر')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('type')
|
|
->label('نوع')
|
|
->badge()
|
|
->formatStateUsing(fn (NotificationType $state): string => $state->label()),
|
|
TextColumn::make('title')
|
|
->label('عنوان')
|
|
->searchable()
|
|
->limit(40),
|
|
IconColumn::make('read_at')
|
|
->label('خوانده شده')
|
|
->boolean()
|
|
->getStateUsing(fn ($record): bool => $record->read_at !== null),
|
|
TextColumn::make('created_at')
|
|
->label('تاریخ ایجاد')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('created_at', 'desc')
|
|
->filters([
|
|
SelectFilter::make('type')
|
|
->label('نوع')
|
|
->options(collect(NotificationType::cases())->mapWithKeys(fn (NotificationType $type) => [$type->value => $type->label()])),
|
|
TernaryFilter::make('read_at')
|
|
->label('وضعیت')
|
|
->placeholder('همه')
|
|
->trueLabel('خوانده شده')
|
|
->falseLabel('خوانده نشده')
|
|
->queries(
|
|
true: fn ($query) => $query->whereNotNull('read_at'),
|
|
false: fn ($query) => $query->whereNull('read_at'),
|
|
),
|
|
])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|