0
我正在使用laravel 5.2。我正在建立一個帖子系統,用戶在其中點擊,點擊給定的圖片。圖像無法顯示在視圖中(laravel 5.2)
正確提取圖像的路徑,但它不顯示在視圖中。同時在視圖中沒有給出錯誤。
我的控制器:
public function createemoji($action,$statusId)
{
$path=('/images/'.$action.'.gif');
$request=new storage();
$request->comment=$path;
$request->user_id=Auth::user()->id;
$request->post_id=$statusId;
$request->save();
$storage=storage::where(function($query) use($statusId)
{
$query->where('post_id',$statusId)
;
})
->orderBy('created_at','desc')->get();
dd($storage);
return redirect()->back()->with('storage',$storage);
}
我的觀點:
<a href="{{route('createemoji',['action'=>'6796','statusid'=>$post->id])}}" id="6796" class="btn btn-sm"><img id="z1" src="/images/6796.gif" name="one"/></a>
的方式我試圖顯示:
@foreach($storages as $storage)
@if($storages==$post->storage)
<div class="row">
<section class=" col-md-offset-3 col-md-5">
<h4 id="h45"></h4>
<img src="{{ $storage->comment }}">
</section>
</div>
@endif
@endforeach
它只能用於單張圖片。我想顯示該帖子的所有圖片。 –
你是否檢查過每個圖像的'$ storage-> comment'值?可能是這個返回不正確的數據? –
我檢查了...它給出正確的數據。 –