/**
  * This url is called when a SEOshop customer installs this application
  *
  * @param Request $request
  * @return \Illuminate\View\View
  * @throws \Exception
  */
 public function install(Request $request)
 {
     // Make sure we have received all required information
     $this->validate($request, ['language' => 'required', 'shop_id' => 'required', 'signature' => 'required', 'timestamp' => 'required', 'token' => 'required']);
     // Validate the signature
     $signature = '';
     $input = $request->except('signature');
     ksort($input);
     // Construct the signature
     foreach ($input as $key => $value) {
         $signature .= $key . '=' . $value;
     }
     // The signature contains the app secret
     $signature = md5($signature . config('services.seoshop.secret'));
     // Do the signatures match?
     if ($signature != $request->input('signature')) {
         throw new \Exception('The signature does not match. You haven\'t secretly tampered with it no?');
     }
     // Find or create the user
     $shop = Shop::firstOrNew(array('shop_id' => $request->input('shop_id')));
     $shop->language = $request->input('language');
     $shop->token = $request->input('token');
     $shop->save();
     // Authenticate the user
     Auth::loginUsingId($shop->id);
     // Create the external services
     Webshop::instance()->installExternalServices();
     // Were done here
     return redirect('dashboard');
 }
 public function store(Request $request)
 {
     $dates = explode(',', $request->input('shopdate'));
     foreach ($dates as $date) {
         $shop = new Shop();
         $shop->user_id = $request->user_id;
         $shop->shopdate = $date;
         $shop->save();
     }
     Flash::success('সঠিক ভাবে সম্পন্ন হয়েছে।');
     return redirect()->back();
 }
 /**
  * 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]);
 }
Beispiel #4
0
 public function listShop()
 {
     $today = date('Y-m-d');
     $shops = Shop::with(['Photo' => function ($query) {
         $query->where('dimension', '=', '200x300')->get();
     }])->get();
     return $shops;
 }
Beispiel #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     //  Shop::truncate();
     $startDate = Carbon::createFromTimeStamp($faker->dateTimeBetween('-1 years', '+1 month')->getTimestamp());
     foreach (range(1, 20) as $index) {
         Shop::create(['name' => $faker->name, 'shopDescription' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'location' => $faker->city, 'contactNumber' => $faker->phoneNumber, 'openingDate' => $startDate->toDateTimeString(), 'email' => $faker->companyEmail]);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('shops', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('floor');
         $table->boolean('lot_no');
         $table->timestamps();
     });
     Shop::create(['name' => 'Midvelly', 'floor' => '10', 'lot_no' => '10-8']);
     Shop::create(['name' => 'KLCC', 'floor' => '11', 'lot_no' => '12-1']);
     Shop::create(['name' => 'Quill', 'floor' => '12', 'lot_no' => '9-2']);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     /**this method selects rules from database and bind to this view whenever it is used */
     view()->composer('partials/dashboardleftcolumn', function ($view) {
         $view->with('rules', \App\Rule::all(['rule_name', 'controller']));
     });
     view()->composer('partials/foodpartial', function ($view) {
         $view->with('items', \App\Item::all());
         //->where(['state',1]);
     });
     view()->composer('menu', function ($view) {
         $view->with('messages', \App\Item::all());
         //->where(['state',1]);
     });
     view()->composer('partials/productform', function ($view) {
         $id = Auth::user()->user_id;
         $view->with('shops', \App\Shop::all()->where('user_id', $id));
     });
 }
Beispiel #8
0
 public function buyItem(Request $request)
 {
     $item = Shop::find($request->get('id'));
     if (!is_null($item)) {
         if ($item->status == Shop::ITEM_STATUS_SOLD) {
             return response()->json(['success' => false, 'msg' => 'Предмет уже куплен!']);
         }
         if ($this->user->money >= $item->price) {
             $item->status = Shop::ITEM_STATUS_SOLD;
             $item->buyer_id = $this->user->id;
             $item->buy_at = Carbon::now();
             $item->save();
             $this->sendItem($item);
             $this->user->money = $this->user->money - $item->price;
             $this->user->save();
             return response()->json(['success' => true, 'msg' => 'Вы успешно купили предмет! Вы получите его в течении 5 минут.']);
         } else {
             return response()->json(['success' => false, 'msg' => 'У вас недостаточно средств для покупки.']);
         }
     } else {
         return response()->json(['success' => false, 'msg' => 'Ошибка! Предмет не найден!']);
     }
 }
Beispiel #9
0
 private function saveArticle(Article $article)
 {
     $article->shop_id = \App\Shop::all()->first()->id;
     if ($article->model_id == '') {
         $article->model_id = null;
     }
     if ($article->brand_id == '') {
         $article->brand_id = null;
     }
     if ($article->part_type_id == '') {
         $article->part_type_id = null;
     }
     // this automatically applies the user id for
     //the relations ship
     //TODO: rever isto para associar a peça à loja de que o user é dono;
     $article->save();
 }
Beispiel #10
0
 public function statistics()
 {
     // Getting data about top 3 products
     $products = App\Product::orderBy('clicks', 'desc')->limit(3)->select(['id', 'item_id', 'clicks', 'views'])->get()->toArray();
     foreach ($products as $key => $product) {
         $products[$key]['img'] = App\Product::find($product['id'])->images()->first()->toArray()['url'];
     }
     // Total clicks and earned money
     $total['clicks'] = App\Product::sum('clicks');
     $total['earned'] = 0;
     // Getting data about shops + clicks per shop
     $shops_query = App\Shop::orderBy('name', 'desc')->select(['id', 'name', 'earned'])->get();
     $shops = [];
     foreach ($shops_query as $shop) {
         $shops[] = ['id' => $shop->id, 'name' => $shop->name, 'earned' => $shop->earned, 'clicks' => round(App\Product::where('shop_id', '=', $shop->id)->sum('clicks'), 2)];
         $total['earned'] += $shop->earned;
     }
     return \View::make('admin/statistics', ['title' => 'Statistiky', 'top_products' => $products, 'shops' => $shops, 'total' => $total]);
 }
Beispiel #11
0
 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;
     }
 }
Beispiel #12
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     return \View::share(['sections' => App\Section::where('parent_id', 0), 'priceRange' => [App\Product::min('price'), App\Product::max('price')], 'favorites' => App\Product::orderBy('views', 'desc')->limit(6)->get(), 'latestPosts' => App\Blog::orderBy('id', 'desc')->limit(4)->get(), 'favSection' => App\Product::orderBy('views', 'desc')->get()->first()->section->name, 'affiliate' => App\Shop::get()]);
 }
Beispiel #13
0
 /**
  * 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'));
 }
Beispiel #14
0
 public function adminChange(User $user, Shop $shop)
 {
     if ($shop->active == 0) {
         //the shop is already disabled
         $shop->update(['active' => 1]);
         Flash::success(trans('admin/messages.shopActivate'));
     } elseif ($shop->active == 1) {
         //the shop is already enabled
         $shop->update(['active' => 0]);
         Flash::success(trans('admin/messages.shopBan'));
     }
     return redirect()->back();
 }
 public function deleteShop($id)
 {
     $shop = Shop::find($id);
     $shop->delete();
     DB::table('last_modifications')->truncate();
     DB::table('last_modifications')->insert(['date' => Carbon::now()]);
 }
Beispiel #16
0
 /**
  * Created By Dara on 26/12/2015
  * admin-product management
  */
 public function adminIndex(User $user, Shop $shop)
 {
     $products = $shop->products()->latest()->paginate(20);
     return view('admin.shop.product.index', compact('shop', 'user', 'products'))->with(['title' => 'User Product Management']);
 }
Beispiel #17
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return \View::make('admin.shops.browse', ['title' => 'Obchody', 'shops' => App\Shop::select()->get()]);
 }
 public function saveUpdate(UpdateShopRequest $request)
 {
     $id = $request->shop_id;
     $shop = Shop::findOrFail($id);
     $shop->update($request->all());
     \Session::flash('success', trans('pagination.shopupdate'));
     return view('admin/dashboard');
 }
 public function addShopImage(Requests\ImageRequest $request, $id)
 {
     if ($request->ajax()) {
         $file = $request->file('picture');
         if ($file) {
             $fileName = $this->upload($file, 'shop');
             $shop = Shop::find($id);
             $shop->picture = $fileName;
             $shop->save();
         }
         DB::table('last_modifications')->truncate();
         DB::table('last_modifications')->insert(['date' => Carbon::now()]);
     }
 }
Beispiel #20
0
 public function destroy($id)
 {
     $shop = Shop::findOrFail($id);
     $shop->delete();
     return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Shop has been deleted.'], 200);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $shop_id
  * @return Response
  */
 public function destroy($shop_id)
 {
     $shop = Shop::destroy($shop_id);
     return \Response::json($shop);
 }
 public function update($id, Request $request)
 {
     $asset = Shop::findOrFail($id);
     $asset->update($request->all());
     return redirect('shops');
 }