Files
minicrm/app/Filament/Widgets/ResolvedTicketsWidget.php
phuongtc 887765bbd7 feat: AfterSales CRM - SOP compliant real-estate customer care system
- Departments + cross-department transfer workflow
- Role-based closing (staff→resolved, manager→closed) with proof_of_resolution
- Private file storage with collection system + temporary signed URLs
- Dashboard: resolved tickets table, stats, handler performance bar chart
- Spatie RBAC (admin/manager/staff)
- Notifications: TicketTransferred, TicketClosed (database + mail)
- Pest tests: 8 tests, 21 assertions
- Docker production-ready (Dockerfile + compose + entrypoint)
2026-04-27 05:29:48 +00:00

60 lines
2.1 KiB
PHP

<?php
namespace App\Filament\Widgets;
use App\Filament\Resources\Feedback\FeedbackResource;
use App\Models\Department;
use App\Models\Feedback;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
class ResolvedTicketsWidget extends BaseWidget
{
protected int|string|array $columnSpan = 'full';
public function table(Table $table): Table
{
return $table
->query(
Feedback::query()
->where('status', 'resolved')
->when(
auth()->user()->hasRole('manager'),
function ($q) {
$deptIds = Department::where('manager_id', auth()->id())->pluck('id');
return $q->whereIn('current_department_id', $deptIds);
}
)
)
->columns([
TextColumn::make('id')
->label('#')
->sortable(),
TextColumn::make('title')
->label('Ticket')
->searchable()
->url(fn (Feedback $record): string => FeedbackResource::getUrl('edit', ['record' => $record])),
TextColumn::make('customer.name')
->label('Customer')
->searchable(),
TextColumn::make('assignedTo.name')
->label('Handler'),
TextColumn::make('currentDepartment.name')
->label('Department'),
TextColumn::make('updated_at')
->label('Resolved Date')
->dateTime('d/m/Y')
->sortable(),
])
->defaultSort('updated_at', 'desc')
->heading('Tickets Awaiting Closure (Resolved)')
->description('Tickets that have been resolved and are pending manager review for closure.');
}
public static function canView(): bool
{
return auth()->user()?->hasRole(['admin', 'manager']) ?? false;
}
}