我在从公共文件夹中获取图像时遇到一些问题,在数据库中我有Class
表和UserImage
表,它们以一对一的关系连接在一起。我尝试过使用它,但它只是给我留下空白的结果。
以下是代码:
HomeController中:
personal_info
test.blade.php (我在哪里展示图片)
public function getInfo($id) {
$data = personal_info::where('id', $id)->get();
$data3 = UserImage::where('user_id', $id)->get();
return view('test',compact('data', 'data3'));
Create1Controller:
@foreach ($data as $object)
<b>Name: </b>{{ $object->Name }}<br><br>
@foreach ($data3 as $currentUser)
<img src="{{ asset('public/images/' . $currentUser->name ) }}">
@endforeach
@if ($data3->count())
@foreach ($data3 as $currentUser)
<a href="{!! route('user.upload.image', ['id' => $currentUser->user_id]) !!}">
<button class="btn btn-primary">
<i class ="fa fa-plus"></i>Upload Images
</button>
</a>
@endforeach
@else
<a href="{!! route('user.upload.image', ['id' => $object->id]) !!}">
<button class="btn btn-primary">
<i class ="fa fa-plus"></i>Upload Images
</button>
@endif
@endforeach