當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Customer::findOrFail方法代碼示例

本文整理匯總了PHP中app\models\Customer::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Customer::findOrFail方法的具體用法?PHP Customer::findOrFail怎麽用?PHP Customer::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Customer的用法示例。


在下文中一共展示了Customer::findOrFail方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: editForm

	public function editForm(Request $request, $id){
		$customer = Customer::findOrFail($id);
		if($customer){
			$data = [
				'customer'	=> $customer,
				'subnav'	=> $this->default_sub_nav
			];
			return view('customers.edit', $data);
		}
		return redirect('/customers')->flash('error', 'Customer not found');
	}
開發者ID:nekoTheGreat,項目名稱:CustomerMgt,代碼行數:11,代碼來源:CustomerController.php

示例2: 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)
 {
     $project = Project::find($id);
     if (!$project) {
         return response()->json('Le projet n\'existe pas.', 404);
     }
     $validator = Validator::make($request->all(), ['status' => 'in:draft,accepted,pending,refused,command,billing', 'quotation_price' => 'integer', 'quotation_date' => 'date', 'customer_id' => 'integer']);
     if ($validator->fails()) {
         return response()->json($validator->errors()->all(), 400);
     }
     if ($request->input('customer_id')) {
         try {
             $customer = Customer::findOrFail($request->input('customer_id'));
         } catch (Exception $e) {
             return response()->json('Le client n\'existe pas.', 404);
         }
     }
     $project->update($request->all());
     return $project;
 }
開發者ID:oarGroupeCesi,項目名稱:madera_api,代碼行數:27,代碼來源:ProjectController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['CUSTNAME' => 'required']);
     $customer = Customer::findOrFail($id);
     $customer->update($request->all());
     Session::flash('flash_message', 'Customer updated!');
     return redirect('customers');
 }
開發者ID:wink-,項目名稱:pluto,代碼行數:15,代碼來源:CustomersController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $customer = Customer::findOrFail($id)->delete();
     // redirect
     Session::flash('message', 'Successfully deleted the customer!');
     return redirect('admin/customers');
 }
開發者ID:shihqi,項目名稱:fms,代碼行數:14,代碼來源:CustomerController.php

示例5: lowerList

 public function lowerList(Request $request)
 {
     $customer_id = $request->input('customer_id');
     $customer = Customer::findOrFail($customer_id);
     // $lower_list = Customer::with(['yikangQuestionnaire', 'orders'])->where('referrer_id', $customer->id);
     // $lower_list = \DB::table('customers')
     //     ->leftJoin('yikang_questionnaires', 'customers.id', '=', 'yikang_questionnaires.customer_id')
     //     ->leftJoin('orders', 'customers.id', '=', 'orders.customer_id')
     //     ->where('customers.referrer_id', $customer->id)
     //     ->select('customers.*', 'orders.*');
     $lower_list = \DB::select(\DB::raw('
 SELECT tmp1.*, tmp2.* FROM
 (
     SELECT 
         lowers.*, yikang_questionnaires.id as questionnaire_id, yikang_questionnaires.q1, yikang_questionnaires.q1b, yikang_questionnaires.q2, yikang_questionnaires.q2b, yikang_questionnaires.q3, yikang_questionnaires.q3a, yikang_questionnaires.q3b, yikang_questionnaires.q3c, yikang_questionnaires.q3d, yikang_questionnaires.q3d2, yikang_questionnaires.q3e, yikang_questionnaires.q4
     FROM 
         (SELECT * FROM customers WHERE referrer_id = ' . $customer->id . ') lowers 
     LEFT JOIN
         yikang_questionnaires
     ON lowers.id = yikang_questionnaires.customer_id
 ) tmp1
 LEFT JOIN 
 (   
     SELECT 
         customer_id, sum(cash_payment) as lower_cash_payment_sum, sum(beans_payment) as lower_beans_payment_sum
     FROM
         orders
     WHERE
         customer_id IN (SELECT id FROM customers WHERE referrer_id = ' . $customer->id . ')
     GROUP BY
         customer_id
 ) tmp2
 ON 
     tmp1.id = tmp2.customer_id
     '));
     return response()->json(['success' => true, 'data' => ['lower_list' => $lower_list]]);
 }
開發者ID:whplay,項目名稱:ohmate-shop,代碼行數:37,代碼來源:CustomerController.php


注:本文中的app\models\Customer::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。