我正在使用laravel 5.0。我收到一个错误:“试图获取非对象的属性”。我想通过单击该特定图像来在所需页面上获得图像。页面上有很多图像,我只想在单击任何图像后将其显示在所需的页面上。这是我的代码:
我的路线:
Route::get('/image/big/{id}' ,[
'uses'=>'GalleryController@bigimage',
'as'=>'bigimage'
]);
我的控制器:
public function bigimage($id){
$images=image::findorFail($id);
return view('bigimage' , ['images'=>$images]);
}
我从何处呼叫所需的路线:
@foreach($gallery->images as $image)
<li>
<a href="{{ URL('/image/big/'.$image->id) }}">
<img id="jumboimage2" src="{{ url($image->file_path) }}"></a>
</li>
<li>
<a href="{{ URL('/image/delete/'.$image->id) }}" id="margin">
<span id="margin" class="glyphicon glyphicon-remove-sign"></span></a>
</li>
@endforeach
我要获取所需图像的视图:
<div class="row">
<section class="col-md-3">
@foreach($images as $image)
{{$image->id}}
@endforeach
</section>
</div>
try this one out
$image = image::findOrFail($id);
return view('bigimage' , ['image' => $image])
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句