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


PHP Item::active方法代碼示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $res['status'] = 400;
     $res['message'] = '';
     $res['errors'] = [];
     // $input = $request->only('firstname_quote', 'lastname_quote', 'email_quote', 'phone_quote', 'date_quote', 'time_quote', 'passengers', 'pickup_addr', 'pickup_building', 'pickup_floors', 'pickup_room_no', 'pickup_elevator', 'delivery_addr', 'delivery_building', 'delivery_floors', 'delivery_room_no' , 'delivery_elevator');
     $input = $request->all();
     $data = $input;
     $rules = ['service_type' => 'required|max:150', 'name_quote' => 'required|max:150', 'email_quote' => 'required|email', 'phone_quote' => 'required', 'date_quote' => 'required|max:20', 'passengers' => 'numeric', 'pickup_addr' => 'required|max:255', 'pickup_building' => 'max:255', 'pickup_floors' => 'max:255', 'pickup_room_no' => 'max:255', 'pickup_elevator' => 'max:3', 'delivery_addr' => 'required|max:255', 'delivery_building' => 'max:255', 'delivery_floors' => 'max:255', 'delivery_room_no' => 'max:255', 'delivery_elevator' => 'max:3', 'message_quote' => 'max:1000'];
     $this->validate($request, $rules);
     $items = Item::active()->orderBy('number_in_row')->get();
     foreach ($items as $item) {
         if (!isset($input[$item->id . '___quantity'])) {
             $res['message'] = 'An error occour, please refresh page and try again.';
             return response()->json($res);
         }
         $data['selected_items'][$item->id]['title'] = $item->title;
         $data['selected_items'][$item->id]['image'] = $item->image;
         $data['selected_items'][$item->id]['quantity'] = (int) $input[$item->id . '___quantity'];
     }
     $res['data'] = $data;
     $res['status'] = 200;
     Mail::send('emails.quotation', $res, function ($m) use($data) {
         $m->to(Config::get('constants.admin')['email'], Config::get('constants.admin')['name'])->subject($data['name_quote'] . ' has filled a quotation for you.');
     });
     return response()->json($res);
 }
開發者ID:sherazali123,項目名稱:removals-laravel,代碼行數:32,代碼來源:QuatationController.php


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