<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\QuizQuestion;
use Illuminate\Http\Request;

class QuizQuestionController extends Controller
{
    public function index()
    {
        $quizQuestions = QuizQuestion::all();
        return response()->json($quizQuestions);
    }

    public function show(QuizQuestion $quizQuestion)
    {
        return response()->json($quizQuestion);
    }

    public function store(Request $request)
    {
        // Validation des données du formulaire

        $quizQuestion = QuizQuestion::create($request->all());

        return response()->json($quizQuestion, 201);
    }

    public function update(Request $request, QuizQuestion $quizQuestion)
    {
        // Validation des données du formulaire

        $quizQuestion->update($request->all());

        return response()->json($quizQuestion, 200);
    }

    public function destroy(QuizQuestion $quizQuestion)
    {
        $quizQuestion->delete();

        return response()->json(null, 204);
    }
}