示例#1
0
 public function register(Request $request)
 {
     $validator = Validator::make($request->all(), ['phone' => 'required|unique:customers', 'password' => 'required']);
     if ($validator->fails()) {
         return response()->json(['success' => false, 'error_code' => ErrorConstants::CUSTOMER_REGISTER_VALIDATOR_FAILS, 'error_message' => $validator->errors()->getMessages()]);
     }
     $customer = new Customer();
     $customer->phone = $request->input('phone');
     $customer->password = Hash::make($request->input('password'));
     $customer->save();
     return response()->json(['success' => true, 'data' => ['customer_id' => $customer->id]]);
 }
示例#2
0
 private function generateCustomer($count = 20)
 {
     $conf['locale'] = "cs-CZ";
     //@todo change me
     $fakerino = Fakerino::create($conf);
     $country = new \App\Model\Customer\Country();
     $country->code = "cz";
     $country->name = "Czech republic";
     $country->status_id = self::DEFAULT_STATUS_ID;
     $country->save();
     for ($i = 0; $i < $count; $i++) {
         $customer = new Customer();
         $fakerino = Fakerino::create($conf);
         $data = $fakerino->fake(['namemale', 'surnamemale', 'city', 'postcode', 'street'])->toArray();
         $customer->credentials_id = 22;
         $customer->last_name = $data[1];
         $customer->first_name = $data[0];
         $customer->status_id = self::DEFAULT_STATUS_ID;
         $customer->save();
         $deliveryAddress = new CustomerAddress();
         $deliveryAddress->customer = $customer->id;
         $deliveryAddress->first_name = $data[0];
         $deliveryAddress->last_name = $data[1];
         $deliveryAddress->city = $data[2];
         $deliveryAddress->street = $data[4];
         $deliveryAddress->zip = $data[3];
         $deliveryAddress->type = 'delivery';
         $deliveryAddress->country = $country->id;
         $deliveryAddress->status_id = self::DEFAULT_STATUS_ID;
         $deliveryAddress->save();
         $localAddress = new CustomerAddress();
         $localAddress->customer = $customer->id;
         $localAddress->first_name = $data[0];
         $localAddress->last_name = $data[1];
         $localAddress->city = $data[2];
         $localAddress->street = $data[4];
         $localAddress->zip = $data[3];
         $localAddress->type = 'invoice';
         $localAddress->country = $country->id;
         $localAddress->status_id = self::DEFAULT_STATUS_ID;
         $localAddress->save();
     }
 }