當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProjectRepository::create方法代碼示例

本文整理匯總了PHP中CodeProject\Repositories\ProjectRepository::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProjectRepository::create方法的具體用法?PHP ProjectRepository::create怎麽用?PHP ProjectRepository::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CodeProject\Repositories\ProjectRepository的用法示例。


在下文中一共展示了ProjectRepository::create方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
開發者ID:Julianocs,項目名稱:codeproject_curso,代碼行數:9,代碼來源:ProjectService.php

示例2: create

 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         $project = $this->repository->create($data);
         return self::getProject($project->id);
     } catch (ValidatorException $ex) {
         return ['error' => true, 'message' => $ex->getMessageBag()];
     }
 }
開發者ID:paulohsilvestre,項目名稱:CodeProject,代碼行數:10,代碼來源:ProjectServices.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     try {
         return $this->repository->create($request->all());
     } catch (ValidatorException $e) {
         $error = $e->getMessageBag();
         return ['error' => true, 'message' => "Erro ao cadastrar o projeto, alguns campos são obrigatórios!", 'messages' => $error->getMessages()];
     } catch (\Exception $e) {
         return $this->erroMsgm('Ocorreu um erro ao cadastrar o projeto.');
     }
 }
開發者ID:maiconmarioto,項目名稱:CodeProject,代碼行數:17,代碼來源:ProjectOldController.php

示例4: create

 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return response()->json(['error' => true, 'message' => $e->getMessageBag()]);
     }
     //enviar email
     //dispara notificacao
 }
開發者ID:brunowerneck,項目名稱:codeproject-curso,代碼行數:11,代碼來源:ProjectService.php

示例5: update

 public function update(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível atualizar as informações do projeto. Projeto não encontrado.'];
     }
 }
開發者ID:poyastro,項目名稱:codeproject-curso,代碼行數:11,代碼來源:ProjectService.php

示例6: create

 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         $p = $this->repository->create($data);
         if ($p) {
             return "Projeto criado com sucesso!";
         }
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
開發者ID:BrunoDamiao,項目名稱:Laravel-5.1,代碼行數:12,代碼來源:ProjectService.php

示例7: create

 /**
  * @param array $data
  * @return mixed
  */
 public function create(array $data)
 {
     try {
         $data['owner_id'] = \Authorizer::getResourceOwnerId();
         $this->validator->with($data)->passesOrFail();
         return $this->repository->create($data);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
開發者ID:adrianodrix,項目名稱:codeproject.dev,代碼行數:16,代碼來源:ProjectService.php

示例8: create

 /**
  * @param array $data
  * @return \Illuminate\Http\JsonResponse
  */
 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);
         $create = $this->repository->create($data);
         $msg = "Projeto criado com sucesso.";
         Log::info($msg);
         return response()->json(["message" => $msg, "data" => $create->toArray()], 200);
     } catch (ValidatorException $e) {
         return response()->json([$e->getMessageBag()], 400);
     }
     //QueryException tratado em Exceptions/Handler.php
 }
開發者ID:renatovaler,項目名稱:code-education,代碼行數:17,代碼來源:ProjectService.php

示例9: create

 public function create(array $data)
 {
     // enviar email
     // disparar notificacao
     // postar tweet
     try {
         $this->validator->with($data)->passesOrFail();
         $project = $this->repository->create($data);
         //Adiciona o owner como membro
         $this->project_member_repository->create(['project_id' => $project['data']['id'], 'user_id' => $project['data']['owner_id']]);
         return $project;
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
開發者ID:phelippe,項目名稱:CodeProject,代碼行數:15,代碼來源:ProjectService.php

示例10: create

 public function create(array $data)
 {
     // diversos serviços
     // enviar email
     // disparar notificacao
     try {
         //dd($data);
         $this->validator->with($data)->passesOrFail();
         $result = $this->repository->create($data);
         //dd($result);
         // adiciona somente um membro ao projeto
         if (!empty($result->id) && !empty($data['user_id'])) {
             $this->addMember(['project_id' => $result->id, 'user_id' => $data['user_id']]);
         }
         return $result;
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
開發者ID:voope,項目名稱:CodeProject,代碼行數:19,代碼來源:ProjectService.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     return $this->repository->create($request->all());
 }
開發者ID:estevesklein,項目名稱:CodeProject-curso-laravel,代碼行數:10,代碼來源:ProjectController.php


注:本文中的CodeProject\Repositories\ProjectRepository::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。