当前位置: 首页>>代码示例>>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;未经允许,请勿转载。