user()), 403); return view('qms.issues.create'); } public function store(Request $request, IdentityTeamClient $identity): RedirectResponse { abort_unless(! StaffUx::showBilling($request->user()), 403); $validated = $request->validate([ 'subject' => ['required', 'string', 'max:255'], 'message' => ['required', 'string', 'max:5000'], 'priority' => ['required', 'in:low,normal,high'], ]); $user = $request->user(); $organization = $this->organization($request); $member = $this->member($request); $context = trim(implode("\n", array_filter([ 'App: Ladill Queue', 'Organization: '.($organization->name ?? '—'), 'Role: '.($member?->role ?? '—'), 'Reporter: '.($user->email ?? $user->ownerRef()), '', $validated['message'], ]))); try { $ticket = $identity->createSupportTicket($user->ownerRef(), [ 'subject' => $validated['subject'], 'message' => $context, 'priority' => $validated['priority'], 'tags' => ['staff_issue', 'app:queue'], ], 'queue'); } catch (\Throwable $e) { report($e); return back() ->withInput() ->with('error', 'Could not send your report right now. Please try again in a moment.'); } $ref = (string) ($ticket['ticket_ref'] ?? ''); return redirect() ->route('qms.dashboard') ->with('success', $ref !== '' ? "Issue reported to Ladill support ({$ref}). Our team will follow up." : 'Issue reported to Ladill support. Our team will follow up.'); } }