'server error'), 500); } protected function created($data = 'ok') { $res = Response::json($data, 201); //jsonp if (Input::has('callback')) { $res->setCallback(Input::get('callback')); } return $res; } protected function deleted($data = 'ok') { $res = Response::json($data, 204); //jsonp if (Input::has('callback')) { $res->setCallback(Input::get('callback')); } return $res; } protected function updated($data = 'ok') { $res = Response::json($data, 204); //jsonp if (Input::has('callback')) { $res->setCallback(Input::get('callback')); } return $res; } /** * @param mixed $data * @return mixed */ protected function ok($data = 'ok') { $res = Response::json($data, 200); //jsonp if (Input::has('callback')) { $res->setCallback(Input::get('callback')); } return $res; } protected function error400($data) { return Response::json($data, 400); } protected function error404($data = array('message' => 'Entity Not Found')) { return Response::json($data, 404); } protected function error403($data = array('message' => 'Forbidden')) { return Response::json($data, 403); } protected function error401($data = array('message' => 'You don\'t have access to this item through the API.')) { return Response::json($data, 401); } /** * { * "message": "Validation Failed", * "errors": [ * { * "resource": "Issue", * "field": "title", * "code": "missing_field" * } * ] * } * @param $messages * @return mixed */ protected function error412($messages) { return Response::json(array('message' => 'Validation Failed', 'errors' => $messages), 412); } }