reportable(function (\BadMethodCallException $e) { return app()->environment() !== 'production'; }); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $exception * * @return \Illuminate\Http\Response */ public function render($request, Throwable $exception) { if ($request->wantsJson()) return response()->json( ['error' => $exception->getMessage()], method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : 500 ); return parent::render($request, $exception); } }