handle MethodNotAllowedHttpException laravel

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

Ditulis dalam php. Leave a Comment »

menyembunyikan informasi database pada debug laravel

buka file config/app.php

tambahkan ini

‘debug_blacklist’ =>

[ ‘_COOKIE’ => array_keys($_COOKIE),

‘_SERVER’ => array_keys($_SERVER),

‘_ENV’ => array_keys($_ENV), ],

maka informasi database akan tampil dibintang atau asterix

semoga berguna 🙂

referensi