Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Display all images one by one laravel

On the backend side, my pictures are loaded normally, but I have problems with displaying them on the front

My Model

public function getImageUrl(): ?string
{
  return $this->imageUrl('image');
}

I am trying to display all the images on the page like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My page.blade.php

<?php
use App\Models\Image;

/**
* @var Image[] $images
*/
?>

<h1>Images</h1>

@foreach($images as $image)
  <img src="{{ $image->getImageUrl() }}">
@endforeach

But I am getting an error: Undefined variable: $images

I need to declare this variable with an array of pictures somewhere on the client side or what to do?

My Controller

public function index(Request $request)
    {
        $images = 

        return view('page', compact('images'));
    }

How can I get all the pictures?

>Solution :

Here Image is your model name and you need to select all the images

$image = Image::all();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading