本文整理汇总了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);
}