public function delete($noteId)
 {
     try {
         $this->repository->find($noteId)->delete();
     } catch (\Exception $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
예제 #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($projectId, $id)
 {
     if ($this->checkProjectNotePermissions($projectId) == false) {
         return ['error' => 'Access Forbidden'];
     }
     return $this->repository->find($id);
     //return $this->repository->with(['client', 'user'])->find($id);
 }
 public function delete($id)
 {
     try {
         if ($this->repository->find($id)->delete()) {
             return ['error' => false, 'message' => 'Projeto deletado.'];
         }
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Projeto não encontrado.'];
     }
 }
 /**
  * @param $projectId
  * @param $noteId
  * @return array|mixed
  */
 public function show($projectId, $noteId)
 {
     try {
         $result = $this->repository->find($noteId);
         return $result;
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível encontrar o registro'];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
 public function destroy($id)
 {
     try {
         $project = $this->repository->find($id);
         $project->delete();
         $msg['status'] = "Y";
         $msg['message'] = "Successfully deleted record";
         return $msg;
     } catch (ValidatorException $ex) {
         return ['error' => true, 'message' => $ex->getMessageBag()];
     }
 }
 /**
  * @param array $data
  * @param $file
  * @param $idProject
  * @return array|mixed
  */
 public function create(array $data, $file, $idProject)
 {
     try {
         $data['project_id'] = $idProject;
         $data['extension'] = $file->getClientOriginalExtension();
         $data['size'] = $file->getClientSize();
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);
         if ($data['size'] > $this->sizeMax) {
             throw new ValidatorException('O arquivo enviado é muito grande, envie arquivos de até 2MB.');
         }
         $projectFile = $this->repository->skipPresenter()->create($data);
         $this->storage->put($projectFile->getFileName(), $this->fileSystem->get($file));
         return $this->repository->find($projectFile->id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
예제 #7
0
 public function find($project_id, $note_id)
 {
     $note = ProjectNote::find($note_id);
     if (is_null($note)) {
         return Errors::invalidId($note_id);
     }
     if (is_null(Project::find($project_id))) {
         return Errors::invalidId($project_id);
     }
     if ($note->project_id != $project_id) {
         return Errors::basic("Falha. Projeto " . $project_id . " nao possui a nota " . $note_id);
     }
     return $this->repository->find($note_id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return $this->repository->find($id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $noteId)
 {
     $this->repository->find($noteId)->delete();
 }