コード例 #1
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";
     }
 }
コード例 #2
0
ファイル: UserBeerHelper.php プロジェクト: ktardthong/beerhit
 /**
  *  Convert type ID into something meaningful for human
  */
 public static function type_return($type_id, $user_id, $beer_id, $text = null, $place_id = null, $img_id = null)
 {
     switch ($type_id) {
         //User had this drink
         case '101':
             return "had this drink!";
             break;
             //User like this
         //User like this
         case '102':
             return "like this";
             break;
             //User want this
         //User want this
         case '103':
             return "want this";
             break;
             //Image posted
         //Image posted
         case '200':
             $data = BeerImg::getImage($img_id);
             return " uploaded " . "<img src=\"{$data->path}\" class=\"img-responsive\">";
             break;
             //Check-in
         //Check-in
         case '300':
             $data = Places::userBeerPlace($user_id, $beer_id, $place_id);
             return "check in " . GlobalUrl::place_url($data) . " having " . $data->beer;
             break;
     }
 }
コード例 #3
0
ファイル: BeerController.php プロジェクト: ktardthong/beerhit
 public function upload_callback()
 {
     if (isset(\Auth::user()->id)) {
         if (Input::file('image')) {
             $image_unique_id = date('Ymdhis') . rand(0, 9999);
             $beer_id = Input::get('beer_id');
             $beer_meta = new BeerImg();
             $beer_meta->beer_id = $beer_id;
             $beer_meta->description = Input::get('beer_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->save();
             /*UserActivity*/
             \UserBeerHelper::userLog(\Auth::user()->id, $beer_id, 200, 0, $image_unique_id);
             $page_title = "Uploaded :  Beerhit!";
             $page_descs = "beerhit.com";
             $message = "Thanks you!";
             //Once upload is done, redirect to the image landing page
             return redirect("beer/{$beer_name}/gallery/picture/{$image_unique_id}")->with(compact('page_title', 'page_descs', 'message', 'beer_meta'));
         } else {
             return "no file entered";
         }
     } else {
         return "need to login";
     }
 }
コード例 #4
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";
     }
 }