Laravel multiple Image view

Published 10 months ago by mhhiron123

How to viewmultiple image from database?

Dry7
Dry7
10 months ago (151,880 XP)

@mhhiron123 just a cycle. but if the question is how to display some picture stored in the database, then more details are needed, how it is stored, how it is added.

robrogers3

Image.php //model

//attributes: url, ...

controller:

$images = Image::all();

return view('image.view', compact($images));

in blade:

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

@if($status->image_url != null) @foreach(explode(',',$status->image_url) as $images) -- @endforeach @endif

mhhiron123

The output is::::::Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Invalid argument supplied for foreach() (View: C:\xampp\htdocs\Criminal&Crime_Record_Mangment\resources\views\layouts\app-internal\user_status_layout.blade.php)

Please sign in or create an account to participate in this conversation.