コード例 #1
0
 public function createFile(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);
         $project = $this->projectRepository->skipPresenter()->find($data['project_id']);
         $projectFile = $project->files()->create($data);
         $this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file']));
         return $projectFile;
     } catch (ValidatorException $ev) {
         return ['error' => true, 'message' => $ev->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Projeto não localizado'];
     }
 }
コード例 #2
0
 public function isMember($projectId, $memberId)
 {
     try {
         if ($this->repository->skipPresenter()->find($projectId)->members()->find($memberId)) {
             return ['success' => true, 'message' => 'Usuario faz parte do projeto'];
         }
         return ['success' => false, 'message' => 'Usuario não faz parte do projeto'];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Projeto não localizado'];
     }
 }