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


PHP Customer::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     if ($request->edit != 0) {
         return $this->update($request, $request->edit);
     }
     $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>'))));
     }
     DB::beginTransaction();
     $customer = new Customer();
     $customer->username = $request->email;
     $customer->email = $request->email;
     $customer->password = Hash::make($request->password);
     $customer->firstname = $request->firstname;
     $customer->lastname = $request->lastname;
     $customer->address = $request->address;
     $customer->phone = $request->phone;
     $customer->city = ucwords($request->city);
     $customer->province = $request->province;
     $customer->country = $request->country;
     $customer->zipcode = $request->zipcode;
     $customer->facebook = $request->facebook;
     $customer->twitter = $request->twitter;
     // $customer->image_profile = $request->image_profile;
     $customer->newsletter = $request->newsletter;
     $customer->active = $request->active;
     $customer->save();
     DB::commit();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'post success', 'message' => 'Post has been received')));
 }
开发者ID:candrasetiadi,项目名称:nvjvnjsdnnvdvdw,代码行数:38,代码来源:CustomerController.php

示例2: 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(), ['order_id' => 'required|integer|min:1', 'vorname' => 'required|max:255', 'nachname' => 'required|max:255', 'strasse' => 'required|max:255', 'PLZ' => 'required|min:4|max:5', 'stadt' => 'required|max:255']);
     if ($validator->fails()) {
         // Return JSON response with 422 HTTP status code
         return $validator->errors()->all();
     }
     $values = $request->all();
     $values = array_map('trim', $values);
     //remove leading and trailing whitespaces on all values
     $values['group'] = Auth::user()->group;
     // Check whether the order exists and is actually owned by the given group
     $order = Order::where('id', $values['order_id'])->where('group', $values['group'])->firstOrFail();
     unset($values['order_id']);
     // Validation successfull, let's check if we already have a customer with the same namespace
     $customer = Customer::where('vorname', $values['vorname'])->where('nachname', $values['nachname'])->where('strasse', $values['strasse'])->where('PLZ', $values['PLZ'])->where('stadt', $values['stadt'])->where('group', $values['group'])->first();
     Log::Info(print_r($customer, true));
     // if this is a new customer, we create it first
     if (is_null($customer)) {
         //|| $customer->isEmpty()
         $customer = new Customer($values);
         $customer->save();
     }
     $existing_associations = $order->customer()->lists('id');
     // check if the relation between order and customer is already established
     if (!in_array($customer->id, array_values($existing_associations->toArray()))) {
         // link the customer to the order
         $order->customer()->attach($customer->id);
     }
     // Return customer object
     return $customer;
 }
开发者ID:Balauue,项目名称:komilitona,代码行数:38,代码来源:CustomerController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $employee_ids = Employee::all()->lists('id')->toArray();
     $order_states = OrderState::lists('id')->toArray();
     $products = Product::all();
     $municipalities = Municipality::all();
     factory(App\Customer::class, 50)->create()->each(function ($customer) use($employee_ids, $products, $municipalities, $order_states) {
         shuffle($employee_ids);
         shuffle($order_states);
         $customer->user()->save(factory(User::class, 'customer')->create());
         $customer->city_id = $municipalities->shuffle()->first()->id;
         $customer->save();
         $customer->products()->attach($products->shuffle()->first(), ['vote' => rand(1, 5), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
         $customer->orders()->save(factory(App\Order::class)->create(['acquired_by' => $employee_ids[0], 'state_id' => $order_states[0]]));
     });
     $user = new User();
     $user->name = 'Vid';
     $user->surname = 'Mahovic';
     $user->email = 'vid.mahovic@gmail.com';
     $user->password = 'vid123';
     $user->verified = true;
     $user->save();
     $customer = new Customer();
     $customer->street = 'Celovška 21';
     $customer->city_id = $municipalities->shuffle()->first()->id;
     $customer->phone = '+38640850993';
     $customer->save();
     $customer->user()->save($user);
 }
开发者ID:vidmahovic,项目名称:ep-store,代码行数:34,代码来源:CustomersTableSeeder.php

示例4: saveCustomer

 public function saveCustomer(Request $request)
 {
     if ($request->customer_id != "") {
         $customer = Customer::find($request->customer_id);
         $customer->name = $request->name;
         $customer->phone = $request->phone;
         $customer->address = $request->address;
         User::where('userable_id', '=', $request->customer_id)->update(['email' => $request->email, 'banned' => $request->banned]);
         $check = $customer->save();
         if ($check) {
             return "EDIT_SUCCEED";
         } else {
             return "Có lỗi xảy ra. Vui lòng thử lại sau!";
         }
     } else {
         $customer = new Customer();
         $customer->name = $request->name;
         $customer->phone = $request->phone;
         $customer->address = $request->address;
         $check = $customer->save();
         if ($check) {
             $data = array('msg' => 'ADD_SUCCEED', 'customer_id' => $customer->id);
             return $data;
         } else {
             return "Có lỗi xảy ra. Vui lòng thử lại sau!";
         }
     }
 }
开发者ID:phucanhhoang,项目名称:IT4895,代码行数:28,代码来源:CustomerController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CustomerRequest $request)
 {
     // store
     $customers = new Customer();
     $customers->name = Input::get('name');
     $customers->email = Input::get('email');
     $customers->phone_number = Input::get('phone_number');
     $customers->address = Input::get('address');
     $customers->city = Input::get('city');
     $customers->state = Input::get('state');
     $customers->zip = Input::get('zip');
     $customers->company_name = Input::get('company_name');
     $customers->account = Input::get('account');
     $customers->save();
     // process avatar
     $image = $request->file('avatar');
     if (!empty($image)) {
         $avatarName = 'cus' . $customers->id . '.' . $request->file('avatar')->getClientOriginalExtension();
         $request->file('avatar')->move(base_path() . '/public/images/customers/', $avatarName);
         $img = Image::make(base_path() . '/public/images/customers/' . $avatarName);
         $img->resize(100, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save();
         $customerAvatar = Customer::find($customers->id);
         $customerAvatar->avatar = $avatarName;
         $customerAvatar->save();
     }
     Session::flash('message', 'You have successfully added customer');
     return Redirect::to('customers');
 }
开发者ID:rambo82,项目名称:tutapos,代码行数:36,代码来源:CustomerController.php

示例6: doCreate

 public function doCreate(CreateCustomerRequest $request)
 {
     $customer = new Customer();
     $customer->name = $request->name;
     $customer->email = $request->email;
     $customer->class = $request->class;
     $customer->description = $request->description;
     $customer->description_name = $request->description_name;
     $customer->specialty = $request->specialty;
     $customer->mobile = $request->mobile;
     $customer->clinic_tel = $request->clinic_tel;
     $customer->address = $request->address;
     $customer->address_description = $request->address_description;
     $customer->am_working = $request->am_working;
     $customer->mr_id = $request->mr;
     $customer->time_of_visit = $request->time_of_visit;
     $customer->comment = $request->comment;
     $customer->active = $request->active;
     try {
         $customer->save();
         return redirect()->back()->with('message', 'Customer has been added successfully !');
         //            print_r($customer);
     } catch (ParseException $ex) {
         echo 'Failed to create new customer , with error message: ' . $ex->getMessage();
     }
 }
开发者ID:m-gamal,项目名称:crm,代码行数:26,代码来源:CustomerController.php

示例7: create

 public function create(Request $request)
 {
     $deviceId = $request->input('device_id');
     $customer = Customer::where('device_id', $deviceId)->first();
     if (isset($customer)) {
         return json_encode(array('message' => 'existing', 'customer' => $customer));
     } else {
         $phone = $request->input('phone');
         $customer = Customer::where('phone', $phone)->first();
         if (!isset($customer)) {
             $customer = new Customer();
             $customer->name = $request->input('name');
             $customer->phone = $request->input('phone');
             $customer->device_id = $request->input('device_id');
             $customer->password = '';
             //$request->input('password');
             $customer->photo = 'default';
             $customer->status = 'active';
             $customer->created_at = date('Y-m-d h:i:s');
             $customer->updated_at = date('Y-m-d h:i:s');
             $customer->save();
             return json_encode(array('message' => 'done', 'customer' => $customer));
         } else {
             return json_encode(array('message' => 'duplicate'));
         }
     }
 }
开发者ID:ashutoshpandey,项目名称:budget_lara,代码行数:27,代码来源:CustomerController.php

示例8: generateCustomerSeed

 private function generateCustomerSeed($email, $password, $firstname, $surname, $dob)
 {
     $user = ['email' => $email, 'password' => bcrypt($password), 'role' => '1'];
     $user = User::create($user);
     $customer = new Customer();
     $customer->user_id = $user->id;
     $customer->firstname = $firstname;
     $customer->surname = $surname;
     $customer->dob = $dob;
     $customer->save();
 }
开发者ID:jentleyow,项目名称:megadeal,代码行数:11,代码来源:UsersTableSeeder.php

示例9: saveCustomer

 public function saveCustomer(Request $request)
 {
     $this->validate($request, ['address' => 'required|max:200', 'number_card' => 'required|numeric|digits:16']);
     $c = new Customer();
     $c->user_id = Auth::user()->id;
     $c->address = $request->address;
     $c->number_card = $request->number_card;
     $c->number_command = 0;
     $c->save();
     return redirect('commande')->with(['message' => 'Votre inscription est complete', 'alert' => 'success']);
 }
开发者ID:Laurent91700,项目名称:Star-Wars,代码行数:11,代码来源:LoginController.php

示例10: save

 public function save(Request $request)
 {
     if (!Customer::whereCustomer_id($request->customer_id)->first()) {
         $customer = new Customer();
         $customer->fill($request->all());
         $customer->save();
         return redirect("/customer/" . $customer->id . "/show");
     } else {
         return redirect("/customer/create")->with("status", Alert::get("danger", "Kund " . $request->customer_id . " existerar, försök igen."));
     }
 }
开发者ID:znittzel,项目名称:datianew,代码行数:11,代码来源:CustomerController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['customer_name' => 'required|max:255', 'group_list_selected' => 'required']);
     $customer = new Customer(['name' => $request->customer_name]);
     $customer->save();
     // Add the new group - customer association
     foreach ($request->group_list_selected as $g_selected) {
         $customer->groups()->attach($g_selected);
     }
     return redirect('/customers');
 }
开发者ID:stryker250,项目名称:simple_ticket,代码行数:17,代码来源:CustomerController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $customer = new Customer();
     $customer->first_name = $request->input('first_name');
     $customer->last_name = $request->input('last_name');
     $customer->email = $request->input('email');
     $customer->phone = $request->input('phone');
     $customer->facebook_url = $request->input('facebook_url');
     $customer->notes = $request->input('notes');
     $customer->save();
     return response()->json(['newId' => $customer->id]);
 }
开发者ID:breenyoung,项目名称:wfadmin,代码行数:18,代码来源:CustomerController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param \App\Http\Requests\CreateCustomerValidation|\Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCustomerValidation $request)
 {
     $input = $request->all();
     $customer = new Customer();
     $customer->fill($input);
     if ($customer->save()) {
         $this->setMessage('Customer was successfully created!');
     } else {
         $this->setMessage('Oops... Customer was not created.  Please try again', 'error');
     }
     return redirect('/customers');
 }
开发者ID:smadeira,项目名称:yellowBucketLaravel,代码行数:18,代码来源:CustomerController.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = new User();
     $user->name = 'mugekural';
     $user->surname = str_random(10);
     $user->email = $user->name . '@gmail.com';
     $user->is_active = true;
     $user->password = bcrypt('12345');
     $user->type = 'App\\Supplier';
     $user->save();
     $supplier = new Supplier();
     $supplier->phone = '023123';
     $supplier->id = $user->id;
     $supplier->save();
     $user2 = new User();
     $user2->name = str_random(10);
     $user2->surname = str_random(10);
     $user2->email = $user2->name . '@gmail.com';
     $user2->is_active = true;
     $user2->type = 'App\\Customer';
     $user2->save();
     $customer = new Customer();
     $customer->phone = "053247557437";
     $customer->id = $user2->id;
     $customer->save();
     $instagram = new InstagramAccount();
     $instagram->instagram_id = "1231231";
     $instagram->access_token = "asdaddads";
     $instagram->username = "farukaladag";
     $instagram->full_name = "omer faruk";
     $instagram->bio = "fdsfasfdsf";
     $instagram->website = "string";
     $instagram->profile_picture = "";
     $supplier->instagramAccount()->save($instagram);
     $product = new Product();
     $product->supplier_id = $supplier->id;
     $product->id = "235";
     $product->is_active = true;
     $product->title = "kitap";
     $product->description = "martı";
     $product->price = "340";
     $product->save();
     $instagram2 = new InstagramAccount();
     $instagram2->instagram_id = "700797";
     $instagram2->access_token = "fjfjjfjfjf";
     $instagram2->username = "mug9";
     $instagram2->full_name = "muge kural";
     $instagram2->bio = "comp stud";
     $instagram2->website = "some string";
     $instagram2->profile_picture = "";
     $customer->instagramAccount()->save($instagram2);
 }
开发者ID:mg9,项目名称:koalaBazaar,代码行数:57,代码来源:UserTableSeeder.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $customer = new Customer();
     $customer->username = $request->name;
     $customer->email = $request->email;
     $customer->password = Hash::make($request->password);
     if ($customer->save()) {
         \Session::flash('message', 'Utilisateur bien sauvegardé en BDD.');
     } else {
         \Session::flash('message', 'Probleme lors de l\'acces à la BDD. Merci de réessayer.');
     }
     return view('customers.create');
 }
开发者ID:kiinay,项目名称:starwars-project,代码行数:19,代码来源:CustomersController.php


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