本文整理汇总了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()];
}
}
示例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()];
}
}
示例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.');
}
}
示例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
}
示例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.'];
}
}
示例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()];
}
}
示例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()];
}
}
示例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
}
示例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()];
}
}
示例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()];
}
}
示例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());
}