public function register(Request $request)
 {
     $user = $this->registersUsers->register($request->all());
     if (!$user) {
         return \ResponseFractal::respondErrorWrongArgs($this->registersUsers->getErrors());
     }
     return \ResponseFractal::respondCreateItemSucess($user, new UserTransformer());
 }
示例#2
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     if ($e instanceof OAuthException) {
         return \ResponseFractal::setStatusCode($e->httpStatusCode)->respondCustomError($e->getMessage(), $e->errorType, [$e->parameter]);
     }
     if (config('app.debug')) {
         return $this->renderExceptionWithWhoops($e);
     }
     return parent::render($request, $e);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  *
  * @SWG\Get(
  *     path="/profile",
  *     description="Informações do seu perfil",
  *     operationId="api.profile.index",
  *     tags={"dashboard"},
  *     @SWG\Response(
  *          response=200,
  *          description="Lista dados do seu perfil",
  *          @SWG\Schema(ref="#/definitions/User"),
  *     ),
  *     @SWG\Response(
  *          response=400,
  *          description="Erro de requição, faltando token auth",
  *          @SWG\Schema(ref="#/definitions/Error_oAuth")
  *     ),
  *     @SWG\Response(
  *         response=401,
  *         description="Unauthorized action.",
  *     ),
  *     security={
  *         {
  *             "api_oauth": {"read:tasks"}
  *         }
  *     }
  * )
  *
  */
 public function index()
 {
     $user = User::find(\Authorizer::getResourceOwnerId());
     return \ResponseFractal::respondItem($user, new UserTransformer());
 }
 public function update(CategoryRequest $requests, $categorId)
 {
     $category = $this->categoryRepository->find($categorId);
     $category = $requests->update($category);
     return \ResponseFractal::respondUpdateItemSucess($category, new CategoryTransformer());
 }
示例#5
0
 /**
  * @param array $errors
  */
 protected function failedCustomValidate(array $errors)
 {
     $response = \ResponseFractal::respondErrorWrongArgs($errors);
     throw new HttpResponseException($response);
 }
 /**
  * Display tasks from category
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  *
  *  @SWG\Get(
  *     path="/tasks/category/{category}",
  *     description="Lista todas suas tarefas relacionadas a uma categoria",
  *     operationId="api.tasks.category",
  *     tags={"dashboard"},
  *     @SWG\Parameter(
  *          name="category",
  *          in="path",
  *          description="Id da categoria que deseja visualizar as tarefas",
  *          required=true,
  *          type="integer"
  *      ),     
  *     @SWG\Response(
  *          response=200,
  *          description="Lista todas as tarefas do seu perfil",
  *          @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Task") ),
  *     ),
  *     security={
  *         {
  *             "api_oauth": {"oauth:tasks_read"}
  *         }
  *     }
  * )
  *
  */
 public function findByCategory($id)
 {
     $category = $this->categoryRepository->find($id);
     if (is_null($category)) {
         return \ResponseFractal::respondErrorNotFound('Categoria não encontrada');
     }
     $tasks = $this->taskRepository->findByCategory($id)->paginate();
     return \ResponseFractal::respondCollection($tasks, new TaskTransformer());
 }