当前位置: 首页>>代码示例>>PHP>>正文


PHP ProjectRepository::update方法代码示例

本文整理汇总了PHP中CodeProject\Repositories\ProjectRepository::update方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectRepository::update方法的具体用法?PHP ProjectRepository::update怎么用?PHP ProjectRepository::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeProject\Repositories\ProjectRepository的用法示例。


在下文中一共展示了ProjectRepository::update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
开发者ID:BrunoAlvesSantos,项目名称:codeproject-curso,代码行数:9,代码来源:ProjectService.php

示例2: update

 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return response()->json(['error' => true, 'message' => $e->getMessageBag()]);
     } catch (ModelNotFoundException $e) {
         return response()->json(['error' => true, 'message' => "Project id {$id} not found"]);
     }
 }
开发者ID:robinhodemorais,项目名称:codeproject-curso,代码行数:11,代码来源:ProjectService.php

示例3: update

 /**
  * @param array $data
  * @param $id
  * @return mixed
  */
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'No data found'];
     } catch (\Exception $e) {
         return ['error' => true, 'message' => 'An error occurred when trying to update the data. Try again later.'];
     }
 }
开发者ID:motenaiOH,项目名称:GPLaravel,代码行数:18,代码来源:ProjectService.php

示例4: update

 /**
  * @param array $data
  * @param $id
  * @return \Illuminate\Http\JsonResponse
  */
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->setId($id)->passesOrFail(ValidatorInterface::RULE_UPDATE);
         $update = $this->repository->update($data, $id);
         $msg = "Projeto {$id} atualizado com sucesso.";
         Log::info($msg);
         return response()->json(["message" => $msg, "data" => $update->toArray()], 200);
     } catch (ValidatorException $e) {
         return response()->json([$e->getMessageBag()], 400);
     } catch (ModelNotFoundException $e) {
         return response()->json([$e->getMessage()], 404);
     }
     //QueryException tratado em Exceptions/Handler.php
 }
开发者ID:renatovaler,项目名称:code-education,代码行数:20,代码来源:ProjectService.php

示例5: update

 public function update(array $data, $id)
 {
     $project = Project::find($id);
     if (is_null($project)) {
         return Errors::invalidId($id);
     }
     try {
         $this->validator->with($data)->passesOrFail();
         if ($data['owner_id'] != $project->owner_id) {
             return Errors::basic('O dono do projeto nao pode ser alterado!');
         }
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return Errors::basic($e->getMessageBag());
     }
 }
开发者ID:nelioalves,项目名称:teste-team,代码行数:16,代码来源:ProjectService.php

示例6: update

 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->update($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'O Projeto que está tentando atualizar não existe'];
     }
 }
开发者ID:phelippe,项目名称:CodeProject,代码行数:11,代码来源:ProjectService.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     try {
         return $this->repository->update($request->all(), $id);
     } catch (ModelNotFoundException $e) {
         return $this->erroMsgm('Projeto não encontrado.');
     } catch (ValidatorException $e) {
         $error = $e->getMessageBag();
         return ['error' => true, 'message' => "Erro ao atualizar o projeto, alguns campos são obrigatórios!", 'messages' => $error->getMessages()];
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao atualizar o projeto.');
     }
 }
开发者ID:maiconmarioto,项目名称:CodeProject,代码行数:20,代码来源:ProjectOldController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     return $this->repository->update($request->all(), $id);
 }
开发者ID:CursoCodeSquad,项目名称:Laravel,代码行数:11,代码来源:ProjectController.php


注:本文中的CodeProject\Repositories\ProjectRepository::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。