Exemple #1
0
 public static function uploadBeerImg_callback($request, $fileimage)
 {
     $image_unique_id = date('Ymdhis') . rand(0, 9999);
     $beer_meta = new BeerImg();
     $beer_meta->beer_id = $request['beer_id'];
     $beer_meta->description = !empty($request['img_description']) ? $request['img_description'] : null;
     $beer_name = !empty($request['img_description']) ? $request['img_description'] : null;
     $imageName = "beerhit.com_" . strtolower($beer_name) . $request['beer_id'] . $image_unique_id . '.' . $fileimage->getClientOriginalExtension();
     $path = public_path('/images/catalog/' . $imageName);
     $img = ImageManagerStatic::make($fileimage);
     // 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 = $request['fb_place_id'];
     $beer_meta->save();
     \UserBeerHelper::userLog(\Auth::user()->id, $request['beer_id'], 200, $request['fb_place_id'], $image_unique_id);
 }
 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";
     }
 }
 public function commendBeer()
 {
     if (isset(\Auth::user()->id)) {
         $beer_id = Input::get('beer');
         $commend = Input::get('commend');
         switch ($commend) {
             case 1:
                 //drink it
                 //Increment drink in beers table
                 DB::table('beers')->where('id', $beer_id)->increment('drink');
                 //Log activity
                 \UserBeerHelper::userLog(\Auth::user()->id, $beer_id, 101);
                 $drink_stat = DB::table('beers')->where('id', $beer_id)->select('drink')->first();
                 return $drink_stat->drink;
                 break;
             case 2:
                 //like it
                 //Increment drink in like table
                 DB::table('beers')->where('id', $beer_id)->increment('like');
                 //Log activity
                 \UserBeerHelper::userLog(\Auth::user()->id, $beer_id, 102);
                 $drink_stat = DB::table('beers')->where('id', $beer_id)->select('like')->first();
                 return $drink_stat->like;
                 break;
             case 3:
                 //want it
                 //Increment drink in want table
                 DB::table('beers')->where('id', $beer_id)->increment('want');
                 //Log activity
                 \UserBeerHelper::userLog(\Auth::user()->id, $beer_id, 103);
                 $drink_stat = DB::table('beers')->where('id', $beer_id)->select('want')->first();
                 return $drink_stat->want;
                 break;
         }
         //            return $beer_id."-".$commend;
     } else {
         return "need <a href='/login/fb'>log in</a>";
     }
 }
    /**
     * Take beer_id and return rating review in html format
     */
    public static function beerRatingContainer($beer_id)
    {
        $beer_ratings = \UserBeerHelper::getRating($beer_id);
        foreach ($beer_ratings as $br) {
            ?>
        <div class="media">
            <div class="media-left">
                <?php 
            echo \GlobalUrl::user_profile_pic($br->username, $br->avatar, 'img-circle');
            ?>
            </div>
            <div class="media-body">

                <div class="pull-right">
                    <h2><?php 
            echo $br->overall;
            ?>
</h2>
                </div>

                <div class="pull-left">
                    <ul class="nav nav-pills" role="tablist">
                        <?php 
            echo $br->comment;
            ?>
                    </ul>
                    <br>
                    <br>
                    <small>
                        <ul class="nav nav-pills" role="tablist">
                            <div valign="bottom">
                                Taste   <strong>  <?php 
            echo $br->taste;
            ?>
</strong> &bull;
                                Look    <strong>  <?php 
            echo $br->look;
            ?>
</strong> &bull;
                                Smell   <strong>  <?php 
            echo $br->smell;
            ?>
</strong> &bull;
                                Feel    <strong>  <?php 
            echo $br->feel;
            ?>
</strong>
                            </div>
                        </ul>
                    </small>
                </div>
            </div>
        </div>
        <hr>
        <?php 
        }
    }
 public function userRating()
 {
     return \UserBeerHelper::beerRatingUser(Input::get('beer'));
 }