Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skybird120's avatar

QUIZ website

Does anyone have a QUIZ website made with Laravel and I can insert images with these questions?

0 likes
7 replies
OussamaMater's avatar
Level 37

Yes I did, where seem to be the problem?

If you are wondering how to show each image with the question, it's as simple as having image_name column for the questions table, that stores the path of that image or simply the name if you have one single path for all the images (the image will be uploaded when you create the question), and you can even make it optional, so a nullable column, if that question does not have an image you can use a default one for example, a simplified questions table would be:

questions
    id - integer
    question - string
	image_name - string										

And in your blade you will do something like:

<h1>{{ $question->question }}</h1>

<!-- here you include the image -->
<img src="{{ Vite::asset('resources/images/' . $question->image_name ) }}">

<!-- displaying the question's options for the sake of this example -->
@foreach ($question->options as $option)
     <input type="radio" name="option" value="{{ $option->content }}">
     <label for="html">{{ $option->content }}</label>
     <br>
@endforeach

and that's it you should be good to go.

Reference for the assets handling, assuming you are using Laravel 9

2 likes
OussamaMater's avatar

@skybird120 if that's what you are looking for, consider closing the thread by setting a "best answer" for future comers :)

Please or to participate in this conversation.