WIP: SoftDelete Contract/Payment/Customer, collected_by, Notifications, ProjectReport, ExportDebtReport
This commit is contained in:
53
app/Filament/Widgets/RecentNotifications.php
Normal file
53
app/Filament/Widgets/RecentNotifications.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as BaseWidget;
|
||||
|
||||
class RecentNotifications extends BaseWidget
|
||||
{
|
||||
protected int | string | array $columnSpan = 'full';
|
||||
protected static ?int $sort = 1;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(function () {
|
||||
$user = auth()->user();
|
||||
if (! $user) {
|
||||
return \Illuminate\Notifications\DatabaseNotification::query()->whereRaw('1=0');
|
||||
}
|
||||
return $user->notifications()->whereNull('read_at')->latest()->getQuery();
|
||||
})
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('data.title')
|
||||
->label('Tiêu đề')
|
||||
->badge()
|
||||
->color('warning'),
|
||||
|
||||
Tables\Columns\TextColumn::make('data.message')
|
||||
->label('Nội dung')
|
||||
->limit(100),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Thờ gian')
|
||||
->dateTime('d/m/Y H:i')
|
||||
->color('gray'),
|
||||
])
|
||||
->actions([
|
||||
Action::make('markAsRead')
|
||||
->label('Đánh dấu đã đọc')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->color('success')
|
||||
->action(function ($record) {
|
||||
$record->markAsRead();
|
||||
}),
|
||||
])
|
||||
->paginated([5, 10, 25])
|
||||
->emptyStateHeading('Không có thông báo mới')
|
||||
->emptyStateDescription('Bạn sẽ nhận được cảnh báo khi có đợt thanh toán sắp đến hạn.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user