在我的控制器/动作中:
In my controller/action:
if(!empty($_POST))
{
if(Auth::attempt(Input::get('data')))
{
return Redirect::intended();
}
else
{
Session::flash('error_message','');
}
}
Laravel
中是否有检查请求是POST
还是GET
的方法?
Is there a method in Laravel
to check if the request is POST
or GET
?
我已经在 laravel 版本中解决了如下问题:7+
I've solve my problem like below in laravel version: 7+
**In routes/web.php:**
Route::post('url', YourController@yourMethod);
**In app/Http/Controllers:**
public function yourMethod(Request $request) {
switch ($request->method()) {
case 'POST':
// do anything in 'post request';
break;
case 'GET':
// do anything in 'get request';
break;
default:
// invalid request
break;
}
}
这篇关于检查请求是 GET 还是 POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!