/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $today = Carbon::today(); $tomorrow = Carbon::tomorrow(); $tomorrowbookinguser = Booking::where('bookingdate', '=', $tomorrow)->get(); $dt = Carbon::now(); $year = $dt->year; $month = $dt->month; $currentmonthbreakfast = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count(); $currentmonthlunch = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count(); $currentmonthdinner = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count(); $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner; $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount'); $todaydayshop = Shop::where('shopdate', $today)->get(); $tomorrowshop = Shop::where('shopdate', $tomorrow)->get(); $bookings = Booking::where('bookingdate', '=', $today)->get(); $breakfast = Booking::where('bookingdate', '=', $today)->where('breakfast', '=', 'on')->count(); $lunch = Booking::where('bookingdate', '=', $today)->where('lunch', '=', 'on')->count(); $dinner = Booking::where('bookingdate', '=', $today)->where('dinner', '=', 'on')->count(); $t_breakfast = Booking::where('bookingdate', '=', $tomorrow)->where('breakfast', '=', 'on')->count(); $t_lunch = Booking::where('bookingdate', '=', $tomorrow)->where('lunch', '=', 'on')->count(); $t_dinner = Booking::where('bookingdate', '=', $tomorrow)->where('dinner', '=', 'on')->count(); $useraccounts = DB::table('useraccounts')->where('user_id', Auth::user()->id)->select('user_id', DB::raw("SUM(foodamount) AS t_foodamount"), DB::raw("SUM(houserent) AS t_houserent"), DB::raw("SUM(internetbill) AS t_internetbill"), DB::raw("SUM(utlitybill) AS t_utlitybill"), DB::raw("SUM(buabill) AS t_buabill"), DB::raw("SUM(pay) AS t_pay"))->get(); foreach ($useraccounts as $account) { $amount = $account->t_foodamount + $account->t_houserent + $account->t_internetbill + $account->t_utlitybill + $account->t_buabill; $balance = $amount - $account->t_pay; } return view('home', ['bookings' => $bookings, 'breakfast' => $breakfast, 'lunch' => $lunch, 'dinner' => $dinner, 't_breakfast' => $t_breakfast, 't_lunch' => $t_lunch, 't_dinner' => $t_dinner, 'tomorrow' => $tomorrow, 'todaydayshop' => $todaydayshop, 'tomorrowshop' => $tomorrowshop, 'tomorrowbookinguser' => $tomorrowbookinguser, 'balance' => $balance, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'price' => $price]); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function postEdit($id = null) { $rules = array('shop_name' => 'required', 'shop_address' => 'required', 'shop_code' => 'required'); // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $rules); // If validation fails, we'll exit the operation now. if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $data = new Shop(); $data->shop_name = Input::get('shop_name'); $data->shop_address = Input::get('shop_address'); $data->shop_code = Input::get('shop_code'); $data->is_active = Input::has('is_active') ? 1 : 0; //$data->shop_code = Input::get('is_active'); //return $data;exit; //$data->image_name = $safeName; //echo '<pre>'; //print_r($data); //echo '</pre>'; Shop::where('shop_id', $id)->update(['shop_name' => $data->shop_name, 'shop_address' => $data->shop_address, 'shop_code' => $data->shop_code, 'is_active' => $data->is_active]); //return Redirect::back(); $shops = DB::table('shops')->orderBy('shop_id', 'desc')->get(); //print_r($users); return View('admin.shops.index', compact('shops')); }
public function history() { $items = Shop::where('buyer_id', $this->user->id)->orderBy('buy_at', 'desc')->get(); return view('pages.historyShop', compact('items')); }
/** * Insert or Update table from txt file. * * @param array $split_row * @return Response */ public function processRow($split_row) { $mall_name = $split_row[0]; $floor = $split_row[1]; $lot_no = $split_row[2]; $shop = Shop::where('name', $mall_name)->first(); if (isset($shop)) { $shop->name = $mall_name; $shop->floor = $floor; $shop->lot_no = $lot_no; $shop->save(); } else { $shop = new Shop(); $shop->name = $mall_name; $shop->floor = $floor; $shop->lot_no = $lot_no; $shop->save(); } }
public function parseAction(Request $request) { switch ($request->get('action')) { case 'userInfo': $user = User::where('steamid64', $request->get('id'))->first(); if (!is_null($user)) { $games = Game::where('winner_id', $user->id)->get(); $wins = $games->count(); $gamesPlayed = \DB::table('games')->join('bets', 'games.id', '=', 'bets.game_id')->where('bets.user_id', $user->id)->groupBy('bets.game_id')->orderBy('games.created_at', 'desc')->select('games.*', \DB::raw('SUM(bets.price) as betValue'))->get(); $gamesList = []; $i = 0; foreach ($gamesPlayed as $game) { $gamesList[$i] = (object) []; $gamesList[$i]->id = $game->id; $gamesList[$i]->win = false; $gamesList[$i]->bank = $game->price; if ($game->winner_id == $user->id) { $gamesList[$i]->win = true; } if ($game->status != Game::STATUS_FINISHED) { $gamesList[$i]->win = -1; } $gamesList[$i]->chance = round($game->betValue / $game->price, 3) * 100; $i++; } return response()->json(['username' => $user->username, 'avatar' => $user->avatar, 'votes' => $user->votes, 'wins' => $wins, 'url' => 'http://steamcommunity.com/profiles/' . $user->steamid64 . '/', 'winrate' => count($gamesPlayed) ? round($wins / count($gamesPlayed), 3) * 100 : 0, 'totalBank' => $games->sum('price'), 'games' => count($gamesPlayed), 'list' => $gamesList]); } return response('Error. User not found.', 404); break; case 'voteUser': $user = User::where('steamid64', $request->get('id'))->first(); if (!is_null($user)) { if ($user->id == $this->user->id) { return response()->json(['status' => 'error', 'msg' => 'Вы не можете голосовать за себя.']); } $votes = $this->redis->lrange($user->steamid64 . '.user.votes.list', 0, -1); if (in_array($this->user->id, $votes)) { return response()->json(['status' => 'error', 'msg' => 'Вы уже голосовали за этого пользователя.']); } else { $user->votes++; $user->save(); $this->redis->rpush($user->steamid64 . '.user.votes.list', $this->user->id); return response()->json(['status' => 'success', 'votes' => $user->votes]); } } return response('Error. User not found.', 404); break; case 'shopSort': $options = $request->get('options'); if (is_null($options['searchRarity']) || empty($options['searchRarity']) || $options['searchRarity'] == NULL) { $options['searchRarity'] = ["Тайное", "Засекреченное", "Запрещенное", "Промышленное качество", "Армейское качество"]; } if (is_null($options['searchQuality']) || empty($options['searchQuality']) || $options['searchQuality'] == NULL) { $options['searchQuality'] = ["Прямо с завода", "Немного поношенное", "После полевых испытаний", "Поношенное", "Закаленное в боях"]; } if (is_null($options['searchType']) || empty($options['searchType']) || $options['searchType'] == NULL) { $options['searchType'] = ["Нож", "Винтовка", "Дробовик", "Пистолет", "Снайперская винтовка", "Пулемёт"]; } $items = Shop::where('name', 'like', '%' . $options['searchName'] . '%')->whereBetween('price', [$options['minPrice'], $options['maxPrice'] + 1])->whereIn('type', $options['searchType'])->whereIn('rarity', $options['searchRarity'])->whereIn('quality', $options['searchQuality'])->orderBy('price', $options['sort'])->where('status', Shop::ITEM_STATUS_FOR_SALE)->get(); return $items->toArray(); break; } }