Initialer Laravel Commit für BetiX
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
2026-04-04 18:01:50 +02:00
commit 0280278978
374 changed files with 65210 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Http\Controllers;
use App\Models\UserFeedback;
use Illuminate\Http\Request;
use Inertia\Inertia;
class FeedbackController extends Controller
{
public function showForm()
{
return Inertia::render('Feedback');
}
public function store(Request $request)
{
$data = $request->validate([
'category' => 'required|string|in:general,ux,mobile,feature,complaint',
'overall_rating' => 'nullable|integer|min:1|max:5',
'ux_rating' => 'nullable|integer|min:1|max:5',
'comfort_rating' => 'nullable|integer|min:1|max:5',
'mobile_rating' => 'nullable|integer|min:1|max:5',
'uses_mobile' => 'nullable|boolean',
'nps_score' => 'nullable|integer|min:1|max:10',
'ux_comment' => 'nullable|string|max:2000',
'mobile_comment' => 'nullable|string|max:2000',
'feature_request' => 'nullable|string|max:2000',
'improvements' => 'nullable|string|max:2000',
'general_comment' => 'nullable|string|max:2000',
]);
$data['user_id'] = auth()->id();
UserFeedback::create($data);
return back()->with('success', 'Danke für dein Feedback!');
}
// ── Admin ──────────────────────────────────────────────────────────────
public function adminIndex(Request $request)
{
$status = $request->input('status', 'new');
$search = trim($request->input('search', ''));
$query = UserFeedback::with('user')
->orderByDesc('created_at');
if ($status && $status !== 'all') {
$query->where('status', $status);
}
if ($search !== '') {
if (is_numeric($search)) {
$query->where('id', (int) $search);
} else {
$query->whereHas('user', function ($q) use ($search) {
$q->where('username', 'like', '%' . $search . '%');
});
}
}
$feedbacks = $query->paginate(25)->withQueryString();
$stats = [
'total' => UserFeedback::count(),
'new' => UserFeedback::where('status', 'new')->count(),
'read' => UserFeedback::where('status', 'read')->count(),
];
return Inertia::render('Admin/Feedback', [
'feedbacks' => $feedbacks,
'filters' => ['status' => $status, 'search' => $search],
'stats' => $stats,
]);
}
public function adminShow(int $id)
{
$feedback = UserFeedback::with('user')->findOrFail($id);
if ($feedback->status === 'new') {
$feedback->update(['status' => 'read']);
}
return Inertia::render('Admin/FeedbackShow', [
'feedback' => $feedback,
]);
}
public function adminUpdate(Request $request, int $id)
{
$feedback = UserFeedback::findOrFail($id);
$data = $request->validate([
'status' => 'nullable|in:new,read',
'admin_note' => 'nullable|string|max:2000',
]);
$feedback->update(array_filter($data, fn ($v) => $v !== null));
return back()->with('success', 'Gespeichert.');
}
}