本文整理汇总了PHP中app\Customer::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::getUsername方法的具体用法?PHP Customer::getUsername怎么用?PHP Customer::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Customer
的用法示例。
在下文中一共展示了Customer::getUsername方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$validator = \Validator::make($request->all(), ['email' => 'required|unique:customers,email', 'firstname' => 'required']);
if ($validator->fails()) {
return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => implode($validator->errors()->all(), '<br>'))));
}
$customer = new Customer();
$customer->username = $customer->getUsername($request->firstname);
$customer->email = $request->email;
// pass: kibarer // $2y$10$STb5v6UVqr7ZxGj2ixQvseLTpW14aYUiIdKtyUrESkXCh6EAmmXju
$customer->password = \Hash::make($request->password);
// $customer->remember_token = $request->remember_token;
// $customer->confirmation_code = $request->confirmation_code;
// $customer->confirmed = $request->confirmed;
$customer->firstname = $request->firstname;
$customer->lastname = $request->lastname;
$customer->address = $request->address;
$customer->phone = $request->phone;
// find province, country
$city = \App\City::where('city_name', $request->city)->first();
$customer->city = $request->city;
$customer->province = $city->province->province_name;
$customer->country = $city->province->country->nicename;
$customer->zipcode = $request->zipcode;
$customer->facebook = $request->facebook;
$customer->twitter = $request->twitter;
// $customer->image_profile = $request->image_profile;
$customer->newsletter = 1;
$customer->active = 1;
$customer->save();
return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved')));
}
示例2: postRegister
public function postRegister(Request $request)
{
$validator = \Validator::make($request->all(), ['email' => 'required|unique:customers', 'password' => 'required|confirmed', 'firstname' => 'required', 'city' => 'required', 'g-recaptcha-response' => 'required']);
if ($validator->fails()) {
return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => $validator->errors())));
}
$confirmation_code = str_random(30);
$customer = new Customer();
$customer->username = $customer->getUsername($request->firstname);
$customer->email = $request->email;
$customer->password = \Hash::make($request->password);
$customer->firstname = $request->firstname;
$customer->lastname = $request->lastname;
$customer->address = $request->address;
// find province, country
$city = \App\City::where('city_name', $request->city)->first();
$customer->city = $request->city;
$customer->province = $city->province->province_name;
$customer->country = $city->province->country->name;
$customer->confirmation_code = $confirmation_code;
$customer->save();
// send confirm email
$this->sendConfirmationEmail($customer->firstname, $customer->email, $confirmation_code);
// $request->session()->flash('alert-success', 'Thankyou for registration. Please check your email address to activate your account.');
return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'Thanks for registration. Please check your email to activate your account.')));
}
示例3: postRegister
public function postRegister(Request $request)
{
$this->validate($request, ['email' => 'required|unique:Customers', 'password' => 'required|confirmed', 'firstname' => 'required', 'city' => 'required']);
$confirmation_code = str_random(30);
$customer = new Customer();
$customer->username = $customer->getUsername($request->firstname);
$customer->email = $request->email;
$customer->password = \Hash::make($request->password);
$customer->firstname = $request->firstname;
$customer->lastname = $request->lastname;
$customer->address = $request->address;
// find province, country
$city = \App\City::where('city_name', $request->city)->first();
$customer->city = $request->city;
$customer->province = $city->province->province_name;
$customer->country = $city->province->country->nicename;
$customer->confirmation_code = $confirmation_code;
$customer->save();
// send confirm email
$this->sendConfirmationEmail($customer->email, $confirmation_code);
$request->session()->flash('alert-success', 'Thankyou for registration. Please check your email address to activate your account.');
return redirect()->back();
}