/**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     $userRepository = $this->repository->getUsersRepository();
     $user = $userRepository->findByUsername($this->getIdentity()->getRoleId());
     if ($user->getRole() == "admin") {
         return $this->repository->create($data);
     }
     return new ApiProblem(403, 'Sem autorização para criar');
 }
Exemplo n.º 2
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     return $this->repository->create($data);
     //return new ApiProblem(405, 'The POST method has not been defined');
 }