<!-- resources/views/your-page.blade.php -->
@extends('layouts.theme1')

@section('title', 'Dashboard')

@section('style')

<link rel="stylesheet" href="{{ asset('theme1/dist/libs/select2/dist/css/select2.min.css') }}">
    <!-- Custom CSS -->
<link href="{{ asset('theme1/dist/css/style.min.css') }}" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.5/datatables.min.css"/>

@endsection

@section('content')
    <!-- Contenu de votre page -->
<div class="container">
   
    <div class="card">
        <div class="card-header">
            Question #{{ $question->id }}
            <h3>            
                <p><strong>Libelle:</strong> {{ $question->libelle }}</p>
            </h3>

        </div>
        <div class="card-body">
            @if ($question->image)
                <img src="{{ asset('storage/icons/' . $question->image) }}" alt="Question Image" class="img-fluid">
            @else
                <p>No image available.</p>
            @endif
        </div>

        <table class="table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Libelle</th>
                    <th>Description</th>
                    <th>Est-ce la bonne réponse</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                @foreach($question->answers as $answer)
                <tr>
                    <td>{{ $answer->id }}</td>
                    <td>{{ $answer->libelle }}</td>
                    <td>{{ $answer->description }}</td>
                    <td>{{ $answer->isRightAnswer ? 'Yes' : 'No' }}</td>
                     <td>
                        <a href="{{ route('admin.answers.edit2', $answer->id) }}" class="btn btn-warning">Edit</a>
                        <form action="{{ route('admin.answers.destroy2', $answer->id) }}" method="POST" style="display:inline;">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger">Delete</button>
                        </form>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>

    <a href="{{ route('admin.answers.create2', ['question' => $question]) }}" class="btn btn-primary">Ajouter une réponse</a>

    <a href="{{ route('admin.questions.index') }}" class="btn btn-primary mt-3">Back to List</a>
</div>
@endsection
