当前位置: 首页>>代码示例>>PHP>>正文


PHP Customer::create方法代码示例

本文整理汇总了PHP中app\models\Customer::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::create方法的具体用法?PHP Customer::create怎么用?PHP Customer::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Customer的用法示例。


在下文中一共展示了Customer::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['CUSTNAME' => 'required']);
     Customer::create($request->all());
     Session::flash('flash_message', 'Customer added!');
     return redirect('customers');
 }
开发者ID:wink-,项目名称:pluto,代码行数:12,代码来源:CustomersController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::where('name', 'admin')->first();
     $customer = Customer::create(['name' => 'test']);
     $customer->user()->save(new User(['email' => 't@t.test', 'password' => bcrypt('testing')]));
     $customer->user->assignRole($role);
 }
开发者ID:RichardMarbach,项目名称:mkdir,代码行数:12,代码来源:UserTableSeeder.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validation_rules($request);
     $customer = $request->input();
     Customer::create($customer);
     Session::flash('flash_message', 'Data pelanggan berhasil ditambahkan!');
     return redirect('admin/customer');
 }
开发者ID:thesaputra,项目名称:xyz-prx,代码行数:14,代码来源:CustomerController.php

示例4: 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(), ['lastname' => 'required', 'firstname' => 'required', 'email' => 'required|email|unique:customers', 'adr_street' => 'required', 'adr_zipcode' => 'required', 'adr_city' => 'required']);
     if ($validator->fails()) {
         return response()->json($validator->errors()->all(), 400);
     }
     $customer = Customer::create($request->all());
     return $customer;
 }
开发者ID:oarGroupeCesi,项目名称:madera_api,代码行数:15,代码来源:CustomerController.php

示例5: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $customer = Customer::where('name', $data['name'])->first();
     if (!$customer) {
         $customer = Customer::create($data);
     }
     // We'll need to link the customer and user in this method
     $user = User::create(['email' => $data['email'], 'password' => bcrypt($data['password']), 'sex' => $data['sex'], 'birthdate' => $data['birthdate'], 'customer_id' => $customer->id]);
     event(new UserRegistered($user));
     return $user;
 }
开发者ID:TAEJUNG-KIM,项目名称:mkdir,代码行数:17,代码来源:AuthController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(Request::all(), ['name' => 'required', 'document' => 'required', 'email' => 'required|email|max:255|unique:customers', 'phone' => 'required', 'version_id' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         if (!$this->valDocument(Input::get('document'))) {
             return redirect()->back()->withErrors(['The document field is invalid.']);
         }
         $customer = Request::all();
         Customer::create($customer);
         return redirect('customers');
     }
 }
开发者ID:igormoura,项目名称:ecclesia,代码行数:20,代码来源:CustomerController.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     try {
         $user = \Helper::getSessionCachedUser();
         $customer = Customer::where('openid', $user['openid'])->firstOrFail();
         return $next($request);
     } catch (UserNotSubscribedException $e) {
         return redirect(AppConstant::ATTENTION_URL);
     } catch (UserNotCachedException $e) {
         return redirect(AppConstant::ATTENTION_URL);
     } catch (ModelNotFoundException $e) {
         /** @var array $user */
         Customer::create(['openid' => $user['openid'], 'nickname' => $user['nickname'], 'unionid' => isset($user['unionid']) ? $user['unionid'] : null, 'head_image_url' => $user['headimgurl'], 'type_id' => 1]);
         return $next($request);
     }
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:23,代码来源:CreateIfNotExist.php

示例8: addCustomer

 /**
  * Function to add a new customer to the database
  *
  * Returns customer id for appointment creation
  *
  **/
 public static function addCustomer()
 {
     // We get appointment information then set up our validator
     $info = Session::get('appointmentInfo');
     $validator = Validator::make(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'email' => $info['email']), array('first_name' => 'exists:customers,first_name', 'last_name' => 'exists:customers,last_name', 'email' => 'exists:customers,email'));
     // If the validator fails, that means the user does not exist
     // If any of those three variables don't exist, we create a new user
     // This is so that families can use the same e-mail to book, but
     // We stil create a new user for them in the database.
     if ($validator->fails()) {
         // Registering the new user
         return Customer::create(array('first_name' => $info['fname'], 'last_name' => $info['lname'], 'contact_number' => $info['number'], 'email' => $info['email'], 'wants_updates' => Session::get('updates')))->id;
     } else {
         return Customer::where('email', $info['email'])->pluck('id');
     }
 }
开发者ID:jacobDaeHyung,项目名称:booking-app,代码行数:22,代码来源:Customer.php

示例9: webShopIndex

 public function webShopIndex(Request $request)
 {
     if ($request->has('cooperator_id')) {
         \Session::put('cooperator_id', $request->input('cooperator_id'));
     }
     if (!\Helper::hasSessionCachedUser()) {
         $user = \Wechat::authorizeUser($request->fullUrl());
         if ($user) {
             \Session::put(AppConstant::SESSION_USER_KEY, $user->all());
         } else {
             \Session::put(AppConstant::SESSION_USER_KEY, null);
         }
     }
     $user = \Helper::getSessionCachedUser();
     $customer = \Helper::getCustomerOrNull();
     if (!$customer) {
         $customer = Customer::create(['openid' => $user['openid'], 'referrer_id' => 0, 'type_id' => 1]);
         $customer->update(['cooperator_id' => $request->input('cooperator_id', null)]);
         return redirect('http://web.ohmate.cn/redirect/shop-index?customer_id=' . $customer->id . '&first_in=1');
     }
     return redirect('http://web.ohmate.cn/redirect/shop-index?customer_id=' . $customer->id);
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:22,代码来源:RedirectController.php

示例10: postForm

 public function postForm(FormCustomerRequest $request)
 {
     if (!empty($request)) {
         $data = $request->all();
         $data['company_id'] = 1;
         $data['type'] = 3;
         $data['flagactive'] = $request->get('flagactive', 1);
         unset($data['password']);
         $password = $request->get('password', null);
         if (!empty($password)) {
             $data['password'] = Hash::make($request->get('password'));
         }
         if ($request->id) {
             $obj = Customer::find($request->id);
             $obj->update($data);
         } else {
             $obj = Customer::create($data);
         }
         return redirect('admclient/' . self::NAMEC)->with('messageSuccess', 'Perfil Guardado');
     }
     return redirect('admclient')->with('messageError', 'Error al guardar el perfil');
 }
开发者ID:josmel,项目名称:hostpots,代码行数:22,代码来源:AdminController.php

示例11: storeProfile

 /**
  * Create and store Customer profile data to database and
  * Associate User to Customer user type as well
  *
  * @param  CustomerProfileRequest $request
  * @return Redirect
  */
 public function storeProfile(CustomerProfileRequest $request)
 {
     $user = $this->user;
     $customer = Customer::create($request->only(['address_addressLine1', 'address_addressLine2', 'address_province', 'address_zipCode', 'landline', 'mobile']));
     $farmAddressArray = [];
     for ($i = 1; $i <= count($request->input('farmAddress.*.*')) / 8; $i++) {
         $farmAddress = new FarmAddress();
         $farmAddress->name = $request->input('farmAddress.' . $i . '.name');
         $farmAddress->addressLine1 = $request->input('farmAddress.' . $i . '.addressLine1');
         $farmAddress->addressLine2 = $request->input('farmAddress.' . $i . '.addressLine2');
         $farmAddress->province = $request->input('farmAddress.' . $i . '.province');
         $farmAddress->zipCode = $request->input('farmAddress.' . $i . '.zipCode');
         $farmAddress->farmType = $request->input('farmAddress.' . $i . '.farmType');
         $farmAddress->landline = $request->input('farmAddress$farmAddressArray.' . $i . '.landline');
         $farmAddress->mobile = $request->input('farmAddress.' . $i . '.mobile');
         array_push($farmAddressArray, $farmAddress);
     }
     $customer->users()->save($user);
     $customer->farmAddresses()->saveMany($farmAddressArray);
     $user->update_profile = 0;
     $user->save();
     return redirect()->route('customer.edit')->with('message', 'Profile completed.');
 }
开发者ID:swinecommerceph,项目名称:swinecommerceph,代码行数:30,代码来源:CustomerController.php

示例12: add

	public function add(Request $request){
		$customer = Customer::create($request->all());
		return redirect('/customers');
	}
开发者ID:nekoTheGreat,项目名称:CustomerMgt,代码行数:4,代码来源:CustomerController.php

示例13: save

 public function save(Request $request)
 {
     $customer = Customer::create($request->all());
     $customers = Customer::all();
     return view('pages.customers', ['customers' => $customers]);
 }
开发者ID:bsampaio,项目名称:LumenExperience,代码行数:6,代码来源:CustomerController.php

示例14: run

 public function run()
 {
     Eloquent::unguard();
     Customer::create(array('first_name' => 'Joe', 'last_name' => 'Danger', 'contact_number' => '6666666666', 'email' => 'joedanger@fuckyou.com', 'wants_updates' => FALSE));
     Customer::create(array('first_name' => 'Todd', 'last_name' => 'Megatron', 'contact_number' => '5555555555', 'email' => 'transformers@eye.io', 'wants_updates' => TRUE));
 }
开发者ID:jacobDaeHyung,项目名称:booking-app,代码行数:6,代码来源:CustomerSeeder.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('payables')->delete();
     DB::table('payable_types')->delete();
     DB::table('job_order_jobs')->delete();
     DB::table('job_orders')->delete();
     DB::table('jobs')->delete();
     DB::table('customer_phones')->delete();
     DB::table('customers')->delete();
     DB::table('users')->delete();
     DB::table('companies')->delete();
     $companies = [];
     foreach (range(0, 2) as $x) {
         $companies[] = \App\Models\Company::create(['name' => "Empresa {$x}", 'email' => "empresa{$x}@teste.com.br", 'cnpj' => '81.748.407/0001-01', 'ie' => '309.639.790.252', 'address' => "Endereço da Empresa {$x}", 'number' => $x, 'district' => "Bairro de Teste {$x}", 'city' => "Cidade de Teste {$x}", 'state' => "Teste", 'zip' => '00000-0' . str_pad($x, 2, '0', STR_PAD_LEFT), 'contact' => "Pessoa de Teste {$x}"]);
     }
     $cid = 0;
     foreach ($companies as $company) {
         $cid += 1;
         User::create(['name' => 'Teste', 'email' => "teste{$cid}@teste.com.br", 'password' => Hash::make('teste')])->company()->associate($company)->save();
         $jobs = [];
         foreach (range(0, 15) as $x) {
             $job = Job::create(['name' => "Serviço de teste {$cid}/{$x}", 'price' => $x * 100, 'description' => "Serviço de teste {$x}"])->company()->associate($company);
             $job->save();
             $jobs[] = $job;
         }
         $customers = [];
         foreach (range(0, 15) as $x) {
             $customer = Customer::create(['name' => "Cliente {$cid}/{$x}", 'email' => "cliente{$x}@teste.com.br", 'cnpj' => '81.748.407/0001-01', 'ie' => '309.639.790.252', 'address' => "Endereço de Teste {$x}", 'number' => $x, 'district' => "Bairro de Teste {$x}", 'city' => "Cidade de Teste {$x}", 'state' => "Teste", 'zip' => '00000-0' . str_pad($x, 2, '0', STR_PAD_LEFT), 'contact' => "Pessoa de Teste {$x}"])->company()->associate($company);
             $customer->save();
             foreach (range(0, rand(1, 5)) as $y) {
                 $customer->phones()->create(['phone' => "1398765432{$y}"]);
             }
             $testJobs = array_pick_index($jobs, array_rand($jobs, 5));
             $customerJobOrder = JobOrder::create(['customer_id' => $customer->id, 'note' => "Nota de teste para o cliente {$cid}/{$x}"])->company()->associate($company);
             $customerJobOrder->save();
             $testJobs = array_map(function ($item) {
                 return ['job_id' => $item->id, 'price' => $item->price];
             }, $testJobs);
             $customerJobOrder->jobs()->sync($testJobs);
             $customerJobOrder->save();
             $customers[] = $customer;
         }
         $payableTypes = [];
         foreach (range(0, 15) as $i) {
             $payableType = PayableType::create(['name' => "Conta de Teste {$cid}/{$i}", 'description' => "Descrição do tipo {$i}"])->company()->associate($company);
             $payableType->save();
             $payableTypes[] = $payableType;
         }
         $payables = [];
         foreach ($customers as $customer) {
             foreach (range(0, rand(1, 5)) as $x) {
                 $type = current(array_pick_index($payableTypes, array_rand($payableTypes, 5)));
                 $payable = \App\Models\Payable::create(['payable_type_id' => $type->id, 'date' => \Carbon\Carbon::now()->addDays(rand(1, 60)), 'status' => rand(1, 2), 'price' => $x * 100, 'description' => "Descrição de uma conta a pagar {$customer->id}/{$x}"])->company()->associate($company);
                 $payable->save();
                 $payables[] = $payable;
             }
         }
     }
     Model::reguard();
 }
开发者ID:schleumer,项目名称:php-mercurio,代码行数:66,代码来源:DatabaseSeeder.php


注:本文中的app\models\Customer::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。