Laravel: Component HttpKernel Exception MethodNotAllowedHttpException No message

Multi tool use
Multi tool use


Laravel: Component HttpKernel Exception MethodNotAllowedHttpException No message



I'm a newbie to this laravel.



i've followed a tutorial and i've checked that i wasn't do anything wrong, and then this error comes up. in this code i tried to Read data from table Inputs and create a page to Insert Data into the database in Inputs table.



TicketController:


public function index(){
$inputs = Inputs::all();
return view('index', [
'inputs' => $inputs
]);
}
public function create(){
return view('create');
}
public function store(Request $request)
{
$inputs = new Inputs();

$inputs->inputName = $request->inputName;
$inputs->inputAddress = $request->inputAddress;
$inputs->inputBDO = Carbon::parse($request->inputBDO);
$inputs->inputEmail = $request->inputEmail;
$inputs->inputPhone = $request->inputPhone;
$inputs->inputJob = $request->inputJob;

$inputs->save();

return redirect('/input');
}



}



Routes:


Route::get('/', 'TicketController@index');
Route::get('/input/create', 'TicketController@create');
Route::post('/input', 'TicketController@store');





Post your blade view code as well
– Mayank Pandeyz
Jul 2 at 6:53





2 Answers
2



You are redirecting back to /input at the end of your store() function. A redirect is done using a GET request, but you only have a POST route assigned to this url.


/input


store()


GET


POST


Route::post('/input', 'TicketController@store');



In laravel MethodNotAllowedHttpException comes when you are referring a route which is not available or its type is mismatch. In your case the issue is same, and it is:


MethodNotAllowedHttpException


return redirect('/input');



&


Route::post('/input', 'TicketController@store');



for the first time when you are posting the from at that time the route method match, but at the time of redirection it is looking for:


Route::get('/input', 'TicketController@store');



which is not present, that's why the error.





In that case use return redirect('/');
– Mayank Pandeyz
Jul 2 at 7:33


return redirect('/');





solved thanks, i used return view before
– Steve Ruru
Jul 2 at 7:34






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

itdx7imyfODg2ZrSIe0oEEbBtBEdz9,q9zas0 OeG08bCcz0xtm3 QWW9e1d3wLqhbKxOqhD7TqPVOGG
Mp0u DOMrIVNU6dA NG,LuKx

Popular posts from this blog

Rothschild family

Cinema of Italy