id) ->with('triggeredBy') ->orderByDesc('created_at'); if ($search = $request->query('search')) { $query->where('recipient_email', 'like', '%' . $search . '%'); } if ($status = $request->query('status')) { if (EmailLogStatus::tryFrom($status)) { $query->where('status', $status); } } if ($templateType = $request->query('template_type')) { if (EmailTemplateType::tryFrom($templateType)) { $query->where('template_type', $templateType); } } if ($eventId = $request->query('event_id')) { $query->where('event_id', $eventId); } if ($personId = $request->query('person_id')) { $query->where('person_id', $personId); } if ($from = $request->query('from')) { $query->where('created_at', '>=', $from); } if ($to = $request->query('to')) { $query->where('created_at', '<=', $to); } $logs = $query->paginate($request->integer('per_page', 15)); return $this->success(EmailLogResource::collection($logs)->response()->getData(true)); } }