Laravel route with parameters

前端 未结 3 1575
陌清茗
陌清茗 2021-01-18 08:28

Am using laravel route for approving some form from email. So i have encrypted some variables and created link which is like



        
3条回答
  •  隐瞒了意图╮
    2021-01-18 09:05

    Usually I use two ways:

    1º way:

    The route:

    Route::get('approveRequest', 'ApproveController@approve');
    

    The controller:

    public function approve (Request $request) {
        $var1 = $request->input('var1');
        $var2 = $request->input('var2');
        
        // (...) do something with $var1 and $var2
    }
    

    2º way:

    The route:

    Route::get('approveRequest/{var1}/{var2}', 'ApproveController@approve');
    

    The controller:

    public function approve ($var1, $var2) {
        
        // (...) do something with $var1 and $var2: they already have a instance
    }
    

提交回复
热议问题