如何使用Laravel返回传递参数?

时间:2016-07-30 07:25:10

标签: php laravel-5

我正在使用Laravel 5.0。我想通过传递参数从当前页面返回到上一页。我的网址中包含所有图片和图库的ID。点击特定图片后,我移动到我的网址中具有该图片ID的另一个页面,现在,我想返回到该图片所属的图库页面。

我的控制器:

   public function viewgallerypics($id){
        $gallery= Gallery::findorFail($id);
        return view('dropzone' , ['gallery'=>$gallery]);
         }

    public function bigimage($id){
       $gallery=Gallery::all();
       $image=image::findorFail($id);
       return view('bigimage' , ['image'=>$image,'gallery'=>$gallery]);

       }

我的路线:

       Route::get('/image/big/{id}' ,[
       'uses'=>'GalleryController@bigimage',
       'as'=>'bigimage'
       ]);


       Route::get('/gallery/view/{id}' ,[
       'uses'=>'GalleryController@viewgallerypics',
       'as'=>'viewpics'
       ]);

我的观点:

    <section class="col-md-1">
    <a class="btn btn-primary btn-lg" 
    href="HERE, WHAT I HAVE TO PASS TO GET MY DESIRED
    PAGE????">Back</a>
    </section>

我想要的页面,我想返回,具体取决于通过路径的id:

 <div class="row">
 <div class="col-md-offset-1 col-md-10">
 <div  id="gallery-images">
 <ul>
 @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
 </ul>
 </div>
 </div>
 </div>

1 个答案:

答案 0 :(得分:0)

使用{{ URL::previous() }}

<section class="col-md-1">
    <a class="btn btn-primary btn-lg" href="{{ URL::previous() }}">Back</a>
</section>