/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //dd($request->all());
     $checkin = new Checkin();
     $checkin->course_id = $request->input('course_id');
     $checkin->user_id = $request->input('user_id');
     $checkin->checkin_longitude = $request->input('checkin_longitude');
     $checkin->checkin_latitude = $request->input('checkin_latitude');
     //dd($checkin);
     $checkin->save();
     redirect('dashboard');
 }
Ejemplo n.º 2
0
 public static function checkin_callback()
 {
     if (isset(\Auth::user()->id)) {
         //All the vars
         $user_id = \Auth::user()->id;
         $beer_id = Input::get('beer_id');
         $fb_place_id = Input::get('fb_place_id');
         $image_unique_id = 0;
         /*
          * If there is any images
          * */
         if (Input::file('image')) {
             $image_unique_id = date('Ymdhis') . rand(0, 9999);
             $beer_meta = new BeerImg();
             $beer_meta->beer_id = $beer_id;
             $beer_meta->description = Input::get('description');
             $beer_name = Input::get('name');
             $imageName = "beerhit.com_" . strtolower($beer_name) . $beer_meta->beer_id . $image_unique_id . '.' . Input::file('image')->getClientOriginalExtension();
             $path = public_path('/images/catalog/' . $imageName);
             $img = ImageManagerStatic::make(Input::file('image'));
             // resize the image to a width of 960
             // and constrain aspect ratio (auto width)
             $img->resize(960, null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             });
             $img->save($path);
             //Save image information to database
             $beer_meta->img_id = $image_unique_id;
             $beer_meta->filename = $imageName;
             $beer_meta->path = '/images/catalog/' . $imageName;
             $beer_meta->user_id = \Auth::user()->id;
             $beer_meta->place_id = $fb_place_id;
             $beer_meta->save();
         }
         $checkin = new Checkin();
         $checkin->user_id = $user_id;
         $checkin->place_id = $fb_place_id;
         $checkin->beer_id = $beer_id;
         $checkin->source = 1;
         //we are using facebook, 1 for now
         $checkin->save();
         $place = ['place_id' => Input::get('fb_place_id'), 'name' => Input::get('location'), 'category' => Input::get('fb_category'), 'street' => Input::get('fb_address'), 'city' => Input::get('fb_city'), 'state' => Input::get('fb_state'), 'zip' => Input::get('fb_zip'), 'latitude' => Input::get('fb_lat'), 'longitude' => Input::get('fb_lng')];
         $place_meta = Places::updateOrCreate(['place_id' => Input::get('fb_place_id')])->update($place);
         //Log information
         \UserBeerHelper::userLog($user_id, $beer_id, 300, $fb_place_id, $image_unique_id);
         return redirect("profile/" . \Auth::user()->username);
     } else {
         return "err - user not login";
     }
 }
Ejemplo n.º 3
0
 public static function checkin_callback()
 {
     if (isset(\Auth::user()->id)) {
         $checkin = new Checkin();
         $checkin->user_id = \Auth::user()->id;
         $checkin->place_id = Input::get('fb_place_id');
         $checkin->beer_id = Input::get('beer_id');
         $checkin->source = 1;
         //we are using facebook, 1 for now
         $checkin->save();
         $place = ['place_id' => Input::get('fb_place_id'), 'name' => Input::get('location'), 'category' => Input::get('fb_category'), 'street' => Input::get('fb_address'), 'city' => Input::get('fb_city'), 'state' => Input::get('fb_state'), 'zip' => Input::get('fb_zip'), 'country' => Input::get('fb_country'), 'latitude' => Input::get('fb_lat'), 'longitude' => Input::get('fb_lng')];
         $place_meta = Places::updateOrCreate(['place_id' => Input::get('fb_place_id')])->update($place);
     } else {
         return "err - user not login";
     }
 }
Ejemplo n.º 4
0
 /**
  * @param int $id The equipment you want to check out on
  * @return \Illuminate\Http\RedirectResponse|string
  */
 public function checkout($id)
 {
     // FindOrFail because we don't want anyone checking out on nonexistant equipment
     $equipment = Equipment::findOrFail($id);
     $user = \Auth::id();
     // Get today's range
     $now = new Carbon('now');
     $start = clone $now->hour(0)->minute(0)->second(0);
     $end = clone $now->hour(23)->minute(59)->second(59);
     // Not checked out, checked in, and checkin was today
     $checkin = Checkin::where('user_id', $user)->where('equipment_id', $id)->whereNotNull('checkin')->whereNull('checkout')->whereBetween('checkin', [$start, $end])->first();
     // No checkin? No dice.
     if ($checkin === null) {
         return "Error: You're not checked in.";
     }
     // All is well, write checkout to database
     $checkin->update(['checkout' => new \DateTime()]);
     return redirect()->back();
     // "You have been checked out";
 }
Ejemplo n.º 5
0
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function stats()
 {
     $user = \Auth::id();
     $now = new Carbon();
     $currentFirstDay = clone $now;
     $currentFirstDay = $currentFirstDay->firstOfMonth();
     $currentLastDay = clone $now;
     $currentLastDay = $currentLastDay->lastOfMonth();
     $thisMonth = Checkin::where('user_id', $user)->whereBetween('checkin', [$currentFirstDay, $currentLastDay])->whereBetween('checkout', [$currentFirstDay, $currentLastDay])->orderBy('checkout')->get();
     $stats['current']['total'] = $thisMonth->sum('burned');
     $stats['current']['min'] = $thisMonth->min('burned');
     $stats['current']['max'] = $thisMonth->max('burned');
     $previousLastDay = clone $currentFirstDay;
     $previousLastDay = $previousLastDay->modify('-1 day');
     $previousFirstDay = clone $previousLastDay;
     $previousFirstDay = $previousFirstDay->firstOfMonth();
     $previousMonth = Checkin::where('user_id', $user)->whereBetween('checkin', [$previousFirstDay, $previousLastDay])->whereBetween('checkout', [$previousFirstDay, $previousLastDay])->orderBy('checkout')->get();
     $stats['previous']['total'] = $previousMonth->sum('burned');
     $stats['previous']['min'] = $previousMonth->min('burned');
     $stats['previous']['max'] = $previousMonth->max('burned');
     if ($stats['current']['total'] < $stats['previous']['total']) {
         $stats['difference'] = $stats['previous']['total'] - $stats['current']['total'];
         $stats['suggestion'] = Equipment::orderBy('calories_pm', 'desc')->first();
     }
     return view('equipment.progress', $stats);
 }
Ejemplo n.º 6
0
 public function userPost_callback()
 {
     if (isset(\Auth::user()->id)) {
         //All the vars
         $user_id = \Auth::user()->id;
         $beer_id = Input::get('beer_id');
         $fb_place_id = Input::get('fb_place_id');
         $image_unique_id = 0;
         if (Input::file('image')) {
             BeerImg::uploadBeerImg_callback(Input::get(), Input::file('image'));
         }
         if (!empty($ratingComment)) {
             //Preparing data to be added
             $beer_meta = \App\BeerRating::Add(Input::get());
             $overall = \App\BeerRating::overallCalc(Input::get());
             //Calculate overall scores
             $beer_meta->overall = round($overall, 1);
             $beer_meta->save();
             //Increment votes tally
             DB::table('beers')->where('id', Input::get('beer_id'))->increment('votes');
             DB::table('beers')->where('id', Input::get('beer_id'))->update(array('scores' => $overall));
         }
         if (!empty($fb_place_id)) {
             $checkin = new Checkin();
             $checkin->user_id = $user_id;
             $checkin->place_id = $fb_place_id;
             $checkin->beer_id = $beer_id;
             $checkin->source = 1;
             //we are using facebook, 1 for now
             $checkin->save();
             $place = ['place_id' => Input::get('fb_place_id'), 'name' => Input::get('location'), 'category' => Input::get('fb_category'), 'street' => Input::get('fb_address'), 'city' => Input::get('fb_city'), 'state' => Input::get('fb_state'), 'zip' => Input::get('fb_zip'), 'latitude' => Input::get('fb_lat'), 'longitude' => Input::get('fb_lng')];
             $place_meta = Places::updateOrCreate(['place_id' => Input::get('fb_place_id')])->update($place);
             //Log information
             \UserBeerHelper::userLog($user_id, $beer_id, 300, $fb_place_id, $image_unique_id);
         }
         return redirect("profile/" . \Auth::user()->username);
     } else {
         return "err - user not login";
     }
 }