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']; } }
public function checkProjectPermissions($projectId) { //$userId = Authorizer::getResourceOwnerId(); if ($this->repository->isOwner($projectId, $this->userId) or $this->repository->hasMember($projectId, $this->userId)) { return true; } return false; }