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


PHP Customer::getRepository方法代碼示例

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


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

示例1: add

 /**
  * @SWG\Api(
  *   path="/customer/add",
  *   @SWG\Operation(
  *     nickname="Add new cusromer",
  *     method="POST",
  *     summary="Add new customer",
  *     notes="Returns customer",
  *     type="Customer",
  *     authorizations={},
  *     @SWG\Parameter(
  *       name="name",
  *       description="Name",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="second_name",
  *       description="Second Name",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="last_name",
  *       description="Last Name",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="email",
  *       description="Email",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="phone",
  *       description="Phone",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="login",
  *       description="Login",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\Parameter(
  *       name="password",
  *       description="Password",
  *       required=true,
  *       type="string",
  *       paramType="form",
  *       allowMultiple=false
  *     ),
  *     @SWG\ResponseMessage(code=500, message="Internal server error")
  *   )
  * )
  */
 public function add()
 {
     $statusCode = 200;
     $inputs = \Input::all();
     $validator = Validator::make($inputs, ['name' => 'required|max:100', 'second_name' => 'required|max:100', 'last_name' => 'required|max:100', 'email' => 'required|email|unique:customers,email', 'phone' => 'required|max:100', 'login' => 'required|unique:customers,login', 'password' => 'required']);
     if ($validator->fails()) {
         $response = ['error' => $validator->errors()];
         $statusCode = 500;
     } else {
         $params = ['name' => $inputs['name'], 'second_name' => $inputs['second_name'], 'last_name' => $inputs['last_name'], 'email' => $inputs['email'], 'phone' => $inputs['phone'], 'login' => $inputs['login'], 'password' => \Hash::make($inputs['password'])];
         $customer = new Models\Customer();
         $customer->getRepository()->saveFromArray($params);
         $customerView = new ModelViews\Customer($customer);
         $response = $customerView->get();
     }
     return \Response::json($response, $statusCode);
 }
開發者ID:procoders,項目名稱:printrock,代碼行數:87,代碼來源:CustomerController.php


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