Hi, iterate over them and print every individual image
@foreach( $row->photos as $photo )
<img src="{{ $photo->name }}" />
@endforeach
Hello, I am new to all of this and this is my first website i have made (classified ads). I am using laravel 5.8 framework with a mysql database. I am trying to figure out how to upload all of my images to a view page.
Currently I have it setup to show only the first photo uploaded to the home page and category page, however, when you click on the page to view the whole ad i want to show all of the photos (think how ebay shows just one photo on the first page but then when you click the ad you can view more photos).
I think my problem lies in my use of strtok for pulling only one photo and then it stops at the ',' which is how my photos are uploaded from the user.
<div class="col-md-12">
<div class="productCard">
<img style=" width:100%;height:100%; " src=<?php echo strtok($row->photos, ',')?> />
<h3 style="margin-bottom: 0px; font-size: medium; font-weight: bold;">${{$row->price}}</h3>
<h3 style="margin-bottom: 0px; font-size: small; font-weight: bold;">{{$row->year}} {{$row->make}} {{$row->model}}</h3>
<h3 style="margin-bottom: 0px; font-size: small;">{{$row->city}} {{$row->state}}</h3>
<h3 style="margin-bottom: 20px; margin-top: 20px; font-size: large;">{{$row->description}}</h3>
here is my controller. I think what i want to do is instead of using strtok use implode if possible? I just dont know how to write that in my blade file?
$ads = new Listings;
$images = $request->file('photos');
$count = 0;
if($request->file('photos')){
foreach($images as $item){
if($count < 6){
$var = date_create();
$date = date_format($var, 'Ymd');
$imageName = $date.'_'.$item->getClientOriginalName();
$item->move(public_path().'/uploads/',$imageName);
$url = URL::to("/").'/uploads/'.$imageName;
$arr[] = $url;
$count++
$image = implode(",", $arr);
$ads->maincategoryid = $request->input('maincategoryid');
$ads->subcategoryid = $request->input('subcategoryid');
$ads->description = $request->input('description');
$ads->year = $request->input('year');
$ads->make = $request->input('make');
$ads->model = $request->input('model');
$ads->price = $request->input('price');
$ads->email = $request->input('email');
$ads->state = $request->input('state');
$ads->city = $request->input('city');
$ads->photos = $image;
$ads->save();
return redirect('/')->with('info', 'Listing published successfully');
Please or to participate in this conversation.