Deploy Ladill Queue / deploy (push) Successful in 56s
Phases 1–6: tickets, counters, displays, appointments, workflows, rules, analytics, reports, feedback, admin, device API, and Gitea deploy workflow for queue.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Qms;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\CustomerFeedback;
|
|
use App\Models\Ticket;
|
|
use App\Services\Qms\AuditLogger;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class FeedbackController extends Controller
|
|
{
|
|
public function show(string $qrToken): View
|
|
{
|
|
$ticket = Ticket::where('qr_token', $qrToken)->firstOrFail();
|
|
abort_unless($ticket->status === 'completed', 404);
|
|
|
|
$existing = CustomerFeedback::where('ticket_id', $ticket->id)->first();
|
|
|
|
return view('qms.feedback.show', compact('ticket', 'existing'));
|
|
}
|
|
|
|
public function store(Request $request, string $qrToken): RedirectResponse
|
|
{
|
|
$ticket = Ticket::where('qr_token', $qrToken)->firstOrFail();
|
|
abort_unless($ticket->status === 'completed', 404);
|
|
abort_if(CustomerFeedback::where('ticket_id', $ticket->id)->exists(), 422, 'Feedback already submitted.');
|
|
|
|
$validated = $request->validate([
|
|
'rating' => ['required', 'integer', 'min:1', 'max:5'],
|
|
'service_quality' => ['nullable', 'integer', 'min:1', 'max:5'],
|
|
'wait_experience' => ['nullable', 'integer', 'min:1', 'max:5'],
|
|
'staff_professionalism' => ['nullable', 'integer', 'min:1', 'max:5'],
|
|
'comments' => ['nullable', 'string', 'max:2000'],
|
|
]);
|
|
|
|
$feedback = CustomerFeedback::create([
|
|
'owner_ref' => $ticket->owner_ref,
|
|
'organization_id' => $ticket->organization_id,
|
|
'ticket_id' => $ticket->id,
|
|
'counter_id' => $ticket->counter_id,
|
|
...$validated,
|
|
]);
|
|
|
|
AuditLogger::record($ticket->owner_ref, 'feedback.submitted', $ticket->organization_id, null, CustomerFeedback::class, $feedback->id);
|
|
|
|
return back()->with('success', 'Thank you for your feedback.');
|
|
}
|
|
}
|