Files
ladill-queue/app/Http/Controllers/Qms/FeedbackAdminController.php
T
isaaccladandCursor 89300fc6d6
Deploy Ladill Queue / deploy (push) Successful in 43s
Drop heroes from analytics pages and remove bordered show cards.
Analytics, Reports, Feedback, and Branches use simple headers again;
report and related show views use shadow panels instead of card borders.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 08:21:35 +00:00

42 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Qms;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Qms\Concerns\ScopesToAccount;
use App\Models\CustomerFeedback;
use App\Services\Qms\OrganizationResolver;
use Illuminate\Http\Request;
use Illuminate\View\View;
class FeedbackAdminController extends Controller
{
use ScopesToAccount;
public function index(Request $request): View
{
$this->authorizeAbility($request, 'feedback.view');
$owner = $this->ownerRef($request);
$organization = $this->organization($request);
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
$feedback = CustomerFeedback::owned($owner)
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->whereHas('ticket', fn ($t) => $t->where('branch_id', $branchScope)))
->with(['ticket', 'counter'])
->latest()
->paginate(30);
$avgRating = CustomerFeedback::owned($owner)
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->whereHas('ticket', fn ($t) => $t->where('branch_id', $branchScope)))
->avg('rating');
return view('qms.feedback.index', [
'feedback' => $feedback,
'organization' => $organization,
'avgRating' => round((float) $avgRating, 1),
]);
}
}