After I deploy my Laravel web application to my host, my code was not work as local. I have a form and POST
it to a route, it calls a controller that handles any type of requests. I want to react for each type of request, but Request::Method()
function returns GET
.
Route:
Route::any('/', [
'as' => 'root', 'uses' => 'WelcomeController@index']);
Blade:
<form action="{{ URL::route('root') }}" method="POST">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}">
<input type="hidden" name="newsId" value="{{ $newsId }}">
<input type="hidden" name="orders" id="orders" value="">
<button class="btn" name="next">NEXT</button>
<button class="btn" name="save">SAVE</button>
</form>
Controller:
if (Request::isMethod('get')) {
$newsId = (Auth::user()->last_news_id % 100) + 1;
$sentences = News::find($newsId)->sentences;
return view('summarizer')->with(['sentences' => $sentences, 'newsId' => $newsId]);
} elseif (Request::isMethod('POST')) {
return 'post';
}
Also I used Request::Method()
and it retures GET
for all time!
I tested this codes in my localhost and it works perfectly.
EDIT: I'm surprising that Input::all() returns empty value too. It works in local well.