buka /app/Exceptions/Handler
tambahkan kode ini atas , use Symfony \ Component \ HttpKernel \ Exception \
MethodNotAllowedHttpException
kemudian
public function render($request, Exception $exception)
{
//tambahkan kode ini
if ($exception instanceof MethodNotAllowedHttpException) {
//jika ajax
if($request->ajax())
{
return response()->json([‘error’ => ‘halaman tidak ditemukan’],401);
}
//jika nonajax
return redirect(‘/home’)->with([‘warning’ => ‘halaman tidak ditemukan’ ]);
}
return parent::render($request, $exception);
}
referensi
https://laracasts.com/discuss/channels/laravel/best-way-to-handle-methodnotallowedhttpexception?page=1
https://laravel.com/docs/5.8/errors
https://github.com/getsentry/sentry-laravel/issues/246