本文整理汇总了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);
}