public function postUpdateDiscount(AddDiscountRequest $request) { Discount::where('id', '=', 1)->update(['h1' => $request['h1']]); Discount::where('id', '=', 1)->update(['h2' => $request['h2']]); Discount::where('id', '=', 1)->update(['DeadLine' => $request['DeadLine']]); return "ok"; }
/** * Форма нового заказа */ public function getNewOrder($user_id = null) { $this->page->title = 'Новый заказ'; $this->page->desc = 'Оформление заказа'; if ($user_id != null && is_numeric($user_id)) { $this->data['person'] = Person::findOrFail($user_id); } else { $this->data['person'] = null; } $this->data['price'] = Price::all(); // Список операторов $this->data['operators'] = Operator::where('user_id', '=', $this->user->id)->lists('name', 'id'); // Список аэропортов $this->data['airports'] = Airport::all()->lists('airport', 'id'); // Кол-во пассажиров $this->data['passengers'] = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10); $transfer = TransferType::all(); foreach ($transfer as $key => $value) { $this->data['transfer_out_' . $value->id] = Discount::where('type', '=', $value->id)->where('date_to', '>=', date('Y-m-d'))->where('date_from', '<=', date('Y-m-d'))->where('direction', '=', 'departure')->first(); } $transfer = TransferType::all(); foreach ($transfer as $key => $value) { $this->data['transfer_in_' . $value->id] = Discount::where('type', '=', $value->id)->where('date_to', '>=', date('Y-m-d'))->where('date_from', '<=', date('Y-m-d'))->where('direction', '=', 'arrivals')->first(); } return $this->render('order.new'); }
/** * Запрос цены на дату */ public function getPrice(Request $request) { // Обрабатываем только AJAX запрос if ($request->ajax()) { $price1 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 1)->first(); $price2 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 2)->first(); $price3 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 3)->first(); $price4 = Discount::where('date_from', '<=', date("Y-m-d 00:00:00", strtotime($request->input('date'))))->where('date_to', '>=', date("Y-m-d 23:59:59", strtotime($request->input('date'))))->where('type', 4)->first(); $base_price = Price::all(); $sum1 = $base_price[0]->price; $sum2 = $base_price[1]->price; $sum3 = $base_price[2]->price; $sum4 = $base_price[3]->price; if ($price1) { $sum1 = $price1->sum; } if ($price2) { $sum2 = $price1->sum; } if ($price3) { $sum3 = $price1->sum; } if ($price4) { $sum4 = $price1->sum; } $res_order = array('price1' => $sum1, 'price2' => $sum2, 'price3' => $sum3, 'price4' => $sum4); return response()->json($res_order); } else { return redirect()->back(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $dis = new Discount(); $dis->where('id', $id)->update(['is_active' => 0]); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $categories = Category::all(array('id', 'name', 'parent_id')); $parent_category['0'] = 'Выберите родительскую категорию'; foreach ($categories as $key => $category) { if ($category->parent_id == '') { $parent_category[$category->id] = $category->name; } } $product = Product::findOrFail($id); $images = Image::where('prod_id', '=', $id)->get(); $category = Category::findOrFail($product->cat_id); $par_cat = Category::where('id', '=', $category->parent_id)->lists('name', 'id'); $cat = array($category->id => $category->name); $discounts = ProdDiscount::where('prod_id', '=', $id)->get(); foreach ($discounts as $key => $discount) { $disc = Discount::where('id', '=', $discount->discount_id)->get(); $discounts[$key]->disc_name = $disc[0]->name; $discounts[$key]->disc_description = $disc[0]->description; $disc_old[$discounts[$key]->id] = $discounts[$key]->disc_name; } $discounts_all = Discount::all(array('id', 'name', 'description')); // $discounts['0'] = 'Выберите скидки'; foreach ($discounts_all as $key => $discount_all) { $disc_all[$discount_all->id] = $discount_all->name; } //dd($disc_old); return view('products.edit', compact('par_cat', 'cat', 'parent_category', 'images', 'discounts', 'disc_old', 'disc_all'))->withProduct($product); }