Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get request input in route closure?

I just finished reading Request chapter. And I want to know how to get request input in route closure?

like image 769
DengDeng Avatar asked Dec 11 '22 17:12

DengDeng


2 Answers

Create a object of Illuminate\Http\Request;

Route::get('/', function (Request $request) {
        $request->all();
    });

Or

Route::get('/', function () {    
    Illuminate\Support\Facades\Input::all();
});
like image 147
Sushant Yadav Avatar answered Dec 13 '22 07:12

Sushant Yadav


You can use a global helper:

Route::get('/', function () {
    request()->id;
});
like image 45
user2094178 Avatar answered Dec 13 '22 06:12

user2094178