feat(admin): manual deposit recording, transaction export, ticket filters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
40bf6b54f9
commit
0cdf224309
@@ -17,26 +17,29 @@ class TicketController extends Controller
|
||||
protected TicketReplyRepositoryInterface $ticketReplyRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* List all tickets (paginated, filterable by status / customer_id / search).
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$filters = $request->validate([
|
||||
'status' => ['nullable', 'array'],
|
||||
'status.*' => ['string', 'in:open,pending,resolved,closed'],
|
||||
'room' => ['nullable', 'string', 'max:50'],
|
||||
'customer_id' => ['nullable', 'integer'],
|
||||
'date_from' => ['nullable', 'date'],
|
||||
'date_to' => ['nullable', 'date'],
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
$query = Ticket::query()
|
||||
->with(['customer'])
|
||||
->latest('id');
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
|
||||
if ($request->filled('customer_id')) {
|
||||
$query->where('customer_id', $request->input('customer_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$query->where('subject', 'like', '%' . $request->input('search') . '%');
|
||||
}
|
||||
->latest('id')
|
||||
->when($filters['status'] ?? null, fn ($q, $status) => $q->whereIn('status', $status))
|
||||
->when($filters['room'] ?? null, fn ($q, $room) => $q->where('room', $room))
|
||||
->when($filters['customer_id'] ?? null, fn ($q, $id) => $q->where('customer_id', $id))
|
||||
->when($filters['date_from'] ?? null, fn ($q, $from) => $q->whereDate('created_at', '>=', $from))
|
||||
->when($filters['date_to'] ?? null, fn ($q, $to) => $q->whereDate('created_at', '<=', $to))
|
||||
->when($filters['search'] ?? null, fn ($q, $search) => $q->where(
|
||||
fn ($q) => $q->where('subject', 'like', "%{$search}%")->orWhere('ticket_num', 'like', "%{$search}%")
|
||||
));
|
||||
|
||||
$paginated = $query->paginate($request->input('per_page', 15));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user