feat: add survey

This commit is contained in:
2026-06-01 09:08:12 +03:30
parent b3a7edf3a5
commit a14267f54f
8 changed files with 448 additions and 0 deletions
+15
View File
@@ -11,6 +11,7 @@
use App\Http\Controllers\WorryController;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\QuestionController;
use App\Http\Controllers\SurveyQuestionController;
use App\Http\Controllers\SliderController;
use App\Http\Controllers\ImageController;
use App\Http\Controllers\MusicController;
@@ -116,6 +117,20 @@
Route::delete('/questions/{question}', [QuestionController::class, 'destroy']);
/// survey questions feature (question + description + single/multi options, answered by users)
// Admin: see all users' answers (must be registered before the resource so it isn't caught by {survey_question}).
Route::middleware('abilities:admin')->group(function () {
// Aggregated analytics — register before the {id} routes so "analytics" isn't read as an id.
Route::get('/admin/survey-questions/analytics', [SurveyQuestionController::class, 'adminAnalytics']);
Route::get('/admin/survey-questions/{id}/analytics', [SurveyQuestionController::class, 'adminAnalytics']);
Route::get('/admin/survey-questions', [SurveyQuestionController::class, 'adminIndex']);
Route::get('/admin/survey-questions/{id}', [SurveyQuestionController::class, 'adminShow']);
});
// User: answer + read questions with their own answers only.
Route::post('/survey-questions/{id}/answer', [SurveyQuestionController::class, 'answer']);
Route::apiResource('survey-questions', SurveyQuestionController::class);
/// slider feature
// Route::get('/slider', [SliderController::class, 'index']);