【发布时间】:2017-02-17 06:25:27
【问题描述】:
我正在使用 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
【问题讨论】:
标签: php laravel laravel-5.2 laravel-routing