В настоящее время я столкнулся с ошибкой, и это говорит о том.
Код: Выделить всё
Method Not Allowed
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for route /profile/details_options Supported methods: POST.
Код: Выделить всё
// this is the current page basically in this page I am viewing a form wherein it will check if the employee username is valid or not...
Route::view('/check_uname', 'template.viewhere')->name('route.name');
// endpoint of the form placed in the /check_uname uri
Route::post('/profile/details_options', [FirstController::class, 'firstEndpointFunction'])->name('uname.details_options');
// endpoint of the form return view of the route('uname.details_opitons) which is the page2.displayPage
Route::post('/profile/verify_changes', [SecondController::class, 'secondEndpointFunction'])->name('verify.detail_changes');
поэтому форма выглядит так:
Код: Выделить всё
Код: Выделить всё
FirstController.php
public function firstEndpointFunction(Request $request)
{
// this is where the logic goes and if the condition is true then i will fetch the data and
// pass it on the page2.DisplayPage
if(true){
return view('page2.displayPage', [
'data' => $data,
'data2' => $data2,
'data3' => $data3
]);
}
else {
}
}
так что на этой странице2.displayPage теперь у меня снова есть форма
Код: Выделить всё
и контроллер для этого для его конечной точки:
Код: Выделить всё
SecondController.php
public function secondEndpointFunction(Request $request)
{
if(true){
return response()->json(['message' => 'The input is correct.']);
}
else{
// throws the error I have mentioned aove. When the users input does not match in the DB
// my main goal is to I want to display an error message to the user that the input
// does not match in the database.
return redirect()->back()->withInput()->withErrors(['error' => 'Nothing has found.']);
}
что я сделал, чтобы исправить, так это ff:
Код: Выделить всё
php artisan route:cache
php artisan route:clear
Надеюсь получить представление о том, как это исправить. Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/786 ... in-laravel