我想在刀片视图中显示图像阵列。我有一个表,其中包含一些字段,如名称,地址,图像。图像多于一个,如何在刀片视图中显示多张图像。
<div class="business-gallery">
<div class="gallery">
{{-- {{dd($business->image)}} --}}
{{-- @json($business->image) --}}
<img src="{{$business['image'][0]}}" alt="Second image" />
</div>
</div>
对于每个循环等都不适合我,我什至可以在视图中获取/显示单个图像
@foreach($business['image'] as $image)
<image src="{{ $business['Name']}}" />
@endforeach
和我的控制器,从那里我将数据保存到DB。没有图像模型,我将图像直接存储到业务模型中
// Business insertion from user side
public function store(Request $request)
{
if ($request->hasFile('pictures')) {
foreach ($request->file('pictures') as $picture) {
$pictures[] = $fileName = time() . $picture->getclientOriginalName();
Storage::put('public/' . $fileName, file_get_contents($picture));
}
Business::create([
'image' => implode(',', $pictures),
'name' => $request->name,
'price' => $request->input('price'),
'description' => $request->input('description'),
'user_id' => $request->input('user'),
'category_id' => $request->input('category'),
'subCategory_id' => $request->input('subCategory'),
'province_id' => $request->input('province'),
'city_id' => $request->input('city'),
]);
}
return redirect('sell-business-form')->with('success', 'Your business is under review, Please wait for confirmation');
public function businessDetail($id)
{
$business = Business::findOrFail($id);
return view('front-end.business-detail', compact('business'));
}
请帮帮我