public function callAction($method, $parameters) { // Only admin can access this controller $user = Auth::user(); if (!$user->is_admin) { return app()->abort(403); } return parent::callAction($method, $parameters); }
/** * Catch not found exceptions * * @param string $method * @param array $parameters * @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response */ public function callAction($method, $parameters) { try { return parent::callAction($method, $parameters); } catch (ChildNodeNotFound $e) { return Response::json(['Child node not found'], \Illuminate\Http\Response::HTTP_NOT_FOUND); } catch (ParentNodeNotFound $e) { return Response::json(['Parent node not found'], \Illuminate\Http\Response::HTTP_NOT_FOUND); } catch (ModelNotFoundException $e) { return Response::json('Node not found', \Illuminate\Http\Response::HTTP_NOT_FOUND); } }