Mysql Laravel-在刀片中显示多个图像
如何在my products.blade.php中显示多个图像 这是我的产品控制器:Mysql Laravel-在刀片中显示多个图像,mysql,laravel,image,Mysql,Laravel,Image,如何在my products.blade.php中显示多个图像 这是我的产品控制器: 当我只上传一张图片时,它会显示在我的刀片上,但当我尝试上传更多图片时,它会显示损坏的图片图标。我希望有人能帮忙 如果$product->images作为带|内爆的字符串保存,当您有多个图像时,您需要在控制器/模型级别或刀片上分解这些图像,并在刀片模板中循环它们 因此,取而代之的是图像}}> 您将需要以下内容: @foreach (explode('|', $product->images) as $ima
当我只上传一张图片时,它会显示在我的刀片上,但当我尝试上传更多图片时,它会显示损坏的图片图标。我希望有人能帮忙 如果$product->images作为带|内爆的字符串保存,当您有多个图像时,您需要在控制器/模型级别或刀片上分解这些图像,并在刀片模板中循环它们 因此,取而代之的是图像}}> 您将需要以下内容:
@foreach (explode('|', $product->images) as $image)
<img style="width:100%" src="/storage/image/{{$image}}">
@endforeach
提示:如果我是你,我会读到关于拉威尔雄辩的变异基因的文章。我想他们会让你的生活更轻松。当你创建/保存一个模型时,你会有一个变异体,它会使你的照片瞬间内爆,当你从数据库中检索它时,它会爆炸。一个指向变异体文档的链接
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">All products
<a href="/products/create" class="btn btn-primary" style="margin-left: 70%">New product +</a></div>
<hr>
<div class="card-body">
@foreach($products as $product)
<h2>{{$product->title}}</h2>
<hr>
<img style="width:100%" src="/storage/image/{{$product->images}}">
<br>
<hr>
@endforeach
<small><?php echo now() ?></small>
</div>
</div>
</div>
</div>
</div>
@endsection
@foreach (explode('|', $product->images) as $image)
<img style="width:100%" src="/storage/image/{{$image}}">
@endforeach