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


PHP Customer::findOrFail方法代码示例

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


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

示例1: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $person = Person::findOrFail($id);
     $customer = Customer::findOrFail($person->customer_id);
     $person->delete();
     return Redirect::action('CustomersController@show', [$customer->slug]);
 }
开发者ID:starkbaum,项目名称:sucon,代码行数:13,代码来源:PersonsController.php

示例2: delAccount

 public function delAccount(Request $request)
 {
     $Account_IDs = json_decode(stripslashes($request->accountIds));
     $check = false;
     foreach ($Account_IDs as $id) {
         $user = User::find($id);
         if ($user->username == Auth::user()->username) {
             return "Không thể xóa account \"" . $user->username . "\"";
         }
         $user->deleted = 1;
         $check = $user->save();
         if ($check) {
             $customer = Customer::findOrFail($user->userable_id);
             $customer->deleted = 1;
             $check = $customer->save();
         } else {
             break;
         }
     }
     if ($check) {
         return "true";
     } else {
         return "Có lỗi xảy ra. Vui lòng thử lại sau!";
     }
 }
开发者ID:phucanhhoang,项目名称:IT4895,代码行数:25,代码来源:UserController.php

示例3: ajaxPlans

 public function ajaxPlans()
 {
     $arr = array();
     $plans = Plan::where('mr_id', \Auth::user()->id)->approved()->get();
     $leave = LeaveRequest::where('mr_id', \Auth::user()->id)->approved()->get();
     $i = 0;
     foreach ($plans as $singlePlan) {
         $arr[$i]['start'] = $singlePlan['date'];
         $arr[$i]['title'] = $singlePlan->comment ? $singlePlan->comment : '';
         $arr[$i]['color'] = 'black';
         $i++;
         foreach (json_decode($singlePlan['doctors']) as $singleDoctorId) {
             $color = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) == true ? 'green' : 'red';
             $url = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) != true ? \URL::route('addReport', $singleDoctorId) : NULL;
             $arr[$i]['url'] = $url;
             $arr[$i]['title'] = Customer::findOrFail($singleDoctorId)->name;
             $arr[$i]['start'] = $singlePlan['date'];
             $arr[$i]['color'] = $color;
             $i++;
         }
     }
     foreach ($leave as $singleLeave) {
         $arr[$i]['title'] = 'Holiday';
         $arr[$i]['start'] = $singleLeave['leave_start'];
         $arr[$i]['end'] = date('Y-m-d', strtotime($singleLeave['leave_end'] . "+1 days"));
         $arr[$i]['color'] = '#9b59b6';
         $arr[$i]['allDay'] = true;
         $i++;
     }
     return json_encode($arr);
 }
开发者ID:m-gamal,项目名称:crm,代码行数:31,代码来源:PlanController.php

示例4: create

 /**
  * Show the form for creating a new resource.
  *
  * @param  int  $customer_id
  * @return \Illuminate\Http\Response
  */
 public function create($customer_id)
 {
     $customer = Customer::findOrFail($customer_id);
     $order = new Order();
     $order->customer_id = $customer->id;
     $order->save();
     return redirect()->route('order.show', $order->id);
 }
开发者ID:alexdachin,项目名称:phppos,代码行数:14,代码来源:OrderController.php

示例5: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($id)
 {
     $customer = Customer::findOrFail($id);
     if ($customer->id != Auth::user()->id) {
         return redirect()->route("admin", Auth::user()->id);
     }
     return view('admin.create', compact('customer'));
 }
开发者ID:sasafister,项目名称:scheduler,代码行数:13,代码来源:CustomersController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $customer = Customer::findOrFail($id);
     $customer->update($request->all());
     if (session('pp_new_order', false)) {
         return redirect()->to('/order/create/' . $customer->id);
     }
     return redirect()->route('customer.index');
 }
开发者ID:alexdachin,项目名称:phppos,代码行数:16,代码来源:CustomerController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (Auth::user()->admin == 1) {
         $customer = Customer::findOrFail($id);
     } else {
         $customer = Customer::where('group', Auth::user()->group)->where('id', $id)->firstOrFail();
     }
     return view('customer.show', ['customer' => $customer]);
 }
开发者ID:Balauue,项目名称:komilitona,代码行数:15,代码来源:CustomerController.php

示例8: delete

 public function delete(Request $request)
 {
     $customer = Customer::findOrFail($request->id);
     $customer->delete_stat = 1;
     $customer->save();
     $customerid = $customer->id;
     $employeeid = Auth::user()->id;
     $log = ActivityLog::create(['employee_id' => $employeeid, 'activity' => 'Delete Suppliers', 'table_affected' => 'customer=', 'primary_key' => $customerid, 'column_affected' => 'delete_stat']);
     return redirect()->route('erp_system.customer.index')->withSuccess('Customer deleted.');
 }
开发者ID:husseinsbm,项目名称:erp-system-prototype,代码行数:10,代码来源:CustomerController.php

示例9: create

 public function create()
 {
     $id = \Request::get('id');
     try {
         $customer = Customer::findOrFail($id);
         return view('transaction.create', compact('customer'));
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         return redirect('transaction')->with('message', 'Data dengan kode transaksi tersebut tidak ditemukan!');
     }
 }
开发者ID:Herlanggaws,项目名称:givani,代码行数:10,代码来源:TransactionController.php

示例10: saveCustomer

 public function saveCustomer($customerId)
 {
     $customer = Customer::findOrFail($customerId);
     $input = \Input::all();
     $customer->fill($input);
     if (!$customer->save()) {
         return \Redirect::route('customers.edit', $customerId)->withErrors($customer->getErrors())->withInput();
     }
     return \Redirect::to('/customers');
 }
开发者ID:bengitiger,项目名称:cleverup-crm-laravel5,代码行数:10,代码来源:CustomerController.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param UpdateCustomerRequest|Request $request
  * @param Customer $customer
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateCustomerRequest $request, $id)
 {
     $customer = Customer::findOrFail($id);
     $customer->street = $request->get('street');
     $customer->city_id = $request->get('city_id');
     $customer->phone = $request->get('phone');
     $customer->save();
     $user = User::findOrFail($customer->user->id);
     $user->name = $request->get('name');
     $user->surname = $request->get('surname');
     $user->email = $request->get('email');
     $user->save();
     $customer->user()->save($user);
     return redirect('/');
 }
开发者ID:vidmahovic,项目名称:ep-store,代码行数:22,代码来源:JustController.php

示例12: sendToCustomer

 public function sendToCustomer($customerId)
 {
     $customer = Customer::findOrFail($customerId);
     $message = Input::get('message');
     if (trim($message)) {
         if ($customer->phone) {
             \Sms::send_sms($customer->phone, $message);
         }
     }
     if (!\Sms::error()) {
         \Session::flash('success', 'Sms sent!');
     } else {
         \Session::flash('error', 'Failed!');
     }
     return \Redirect::back();
 }
开发者ID:bengitiger,项目名称:cleverup-crm-laravel5,代码行数:16,代码来源:SmsController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $cart = $request->session()->get('cart');
     $customer = Customer::findOrFail(auth()->user()->userable_id);
     $order_price = 0;
     $order = Order::create(['ordered_by' => $customer->id, 'state_id' => OrderState::where('name', 'pending')->first()->id]);
     foreach ($cart as $product_id => $quantity) {
         $order->products()->attach($product_id, ['quantity' => $quantity]);
         $product = Product::findOrFail($product_id);
         $product->stock -= $quantity;
         $product->save();
         $order_price += $quantity * $product->price;
     }
     $order->price = $order_price;
     $order->shipping = rand(100, 10000) / 100;
     $order->save();
     $request->session()->forget('cart');
     event(new OrderWasPurchased($order));
     return redirect('customer/purchase/success');
 }
开发者ID:vidmahovic,项目名称:ep-store,代码行数:26,代码来源:OrderController.php

示例14: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(CustomerRequest $request, $id)
 {
     $customer = Customer::findOrFail($id);
     $customer->update($request->all());
     return redirect('customer')->with('message', 'Data berhasil dirubah!');
 }
开发者ID:Herlanggaws,项目名称:givani,代码行数:13,代码来源:CustomerController.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(CustomerRequest $request, $id)
 {
     $customer = Customer::findOrFail($id);
     $customer->update($request->all());
     return redirect('customers');
 }
开发者ID:suxiid,项目名称:application,代码行数:13,代码来源:CustomersController.php


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