Beispiel #1
0
 public function test_max_mind()
 {
     $driver = m::mock(MaxMind::class);
     $driver->makePartial()->shouldAllowMockingProtectedMethods()->shouldReceive('process')->once()->andReturn(new Fluent())->shouldReceive('hydrate')->once()->andReturn(new Position());
     Location::setDriver($driver);
     $this->assertInstanceOf(Position::class, Location::get());
 }
Beispiel #2
0
 public function testLocationDriverGeoPlugin()
 {
     app('config')->set('location.selected_driver', 'GeoPlugin');
     $location = Location::get();
     $this->assertInstanceOf('Stevebauman\\Location\\Objects\\Location', $location);
     $this->assertEquals('Stevebauman\\Location\\Drivers\\GeoPlugin', $location->driver);
     $this->assertFalse($location->error);
 }
 public function add_transaction(Request $request)
 {
     //Geo info
     $location = Location::get();
     $city = $location->cityName;
     $country = $location->countryCode;
     $data = array('uid' => Auth::user()->id, 'flg' => 1, 'cate_id' => $request->cate_id, 'trans_type' => $request->trans_type, 'cc_id' => $request->cc_id, 'bill_id' => $request->bill_id, 'pmt_type' => $request->pmt_type, 'amount' => $request->amount, 'location' => $request->location, 'note' => $request->note, 'trans_date' => $request->trans_date, 'lat' => $location->latitude, 'lng' => $location->longitude, 'cityName' => $city, 'postalCode' => $location->postalCode, 'countryCode' => $country, 'created_at' => Carbon::now(), 'location_provider' => $request->location_provider);
     print_r($data);
     $this->createTransaction($data);
     //return redirect('/profile');
 }
 public function index()
 {
     if (empty(Auth::user()->id)) {
         return redirect('/login');
     }
     $page_title = "Profile - Moneyburi";
     $page_descs = "";
     $user_data = User::find(Auth::user()->id);
     if ($user_data['init_setup'] == 0) {
         return redirect('/init_setup');
     }
     $location = Location::get();
     return view('profile.profile', compact('page_title', 'page_descs', 'location'));
 }
 public function postAuth(Request $request)
 {
     $this->validate($request, ['platform' => 'required', 'udid' => 'required']);
     $device = Device::where('udid', $request->input('udid'))->first();
     if (is_null($device)) {
         $country_code = $request->input('countryCode');
         if (!$country_code) {
             $country_code = Location::get($request->header('x-forwarded-for'), 'countryCode');
         }
         $device = new Device();
         $device->fill($request->all());
         $device->country_code = $country_code;
         $device->save();
     }
     $device = Device::find($device->id);
     $token = JWTAuth::fromUser($device);
     return ['credits' => $device->credits, 'auth_token' => $token, 'sender_id' => env('GCM_SENDER_ID')];
 }
 /**
  * Display the specified resource.
  */
 public function show($slug)
 {
     $page_title = "Beerhit!";
     $page_descs = "what hit you?";
     $location = Location::get();
     //data to display on profile page
     $user = User::where('username', $slug)->first();
     if (!$user) {
         return redirect(404);
     } else {
         $user_checkin = User::getUserCheckIn($user->id);
         $uploaded = BeerImg::userUploaded($user->id);
         $drink_log = UserBeer::userDrinkLog($user->id);
         $userLike = UserBeer::userBeerLike($user->id);
         $drink_cnt = UserBeer::where('user_id', $user->id)->count();
         $user_flg = isset(Auth::user()->id) ? TRUE : FALSE;
         $data = array('page_title' => $page_title, 'page_descs' => $page_descs, 'user' => $user, 'drink_cnt' => $drink_cnt, 'drink_log' => $drink_log, 'drink_uploaded' => $uploaded, 'user_flg' => $user_flg, 'user_like' => $userLike, 'user_checkin' => $user_checkin, 'location' => $location);
         return view('pages.user', $data);
     }
 }
Beispiel #7
0
 public function ajaxCheckin()
 {
     if (isset(\Auth::user()->id)) {
         $location = Location::get();
         $city = $location->cityName;
         $lat = $location->latitude;
         $lng = $location->longitude;
         $distance = 2000;
         //meters
         $limit = 8;
         //QUERY
         $term = Input::get('term');
         $fb = \FacebookHelper::fb_init();
         $response = $fb->get("/search?q={$term}&type=place&center={$lat},{$lng}&distance={$distance}&limit={$limit}", \Auth::user()->access_token);
         $fb_response = $response->getDecodedBody();
         $response_array = \FacebookHelper::fbResponse($fb_response['data']);
         return $response_array;
     } else {
         return "err: need login";
     }
 }
Beispiel #8
0
 public function location()
 {
     $location = Location::get();
     return "{$location->cityName} ,{$location->countryCode}  - From your Internet address";
 }
 public function post_register(Request $request)
 {
     $page_title = "money_bkk!";
     $page_descs = "what hit you?";
     $location = Location::get();
     $city = $location->cityName;
     $country = $location->countryName;
     $birthdate = $request->year . '-' . $request->month . '-' . $request->day;
     $data = array('email' => $request->email, 'password' => $request->password, 'cpassword' => $request->confirmpassword, 'birthdate' => $birthdate, 'gender' => $request->sex, 'city' => $city, 'country' => $country, 'firstname' => $request->first_name, 'lastname' => $request->last_name);
     //Verification
     if ($data['password'] != $data['cpassword']) {
         return redirect('register')->withErrors("password mismatch");
     }
     if (empty($data['email'])) {
         return redirect('register')->withErrors("email is empty");
     }
     //end verification
     //Check if this email is already registered
     $user = User::where('email', $request->email)->first();
     if (empty($user)) {
         if ($this->validator($data)) {
             $this->createUser($data);
             $user = User::where('email', $request->email)->first();
             Mail::send('mails.reg_confirm', ['user' => $user], function ($m) use($user) {
                 $m->to($user->email, $user->firstname . ' ' . $user->lastname)->subject('Welcome to Moneyburi!');
             });
             //                Mail::send('mails.weekly_update', ['user' =>  $user], function ($m) use ($user) {
             //                    $m->to($user->email, $user->firstname.(' ').$user->lastname)->subject('Weekly Update from Moneyburi');
             //                });
             Auth::loginUsingId($user->id);
             return redirect('/');
         }
     } else {
         return redirect('register')->withErrors("user already exist");
     }
 }
Beispiel #10
0
Route::get('ajax/searchBeer', 'BeerController@ajax_search');
Route::post('ajax/commendBeer', 'BeerController@commendBeer');
Route::post('ajax/submitReview', 'BeerController@submitReview');
Route::get('ajax/ajaxCheckin', 'BeerController@ajaxCheckin');
Route::POST('ajax/userRating', 'ProfileController@userRating');
//----------------------------------------------------------------
Route::get('login/fb', function () {
    return \Socialite::with('facebook')->scopes(['email', 'user_friends', 'user_location', 'user_birthday'])->redirect();
});
//http://beerhit.com/login/fb/callback
Route::get('login/fb/callback', function () {
    $socialize_user = \Socialite::with('facebook')->user();
    $facebook_user_id = $socialize_user->getId();
    // unique facebook user id
    $user = User::where('email', $socialize_user->email)->first();
    $location = Location::get();
    $city = $location->cityName;
    $country = $location->countryName;
    //    dd($socialize_user);
    if (!$user) {
        $user = new User();
        $user->fb_id = $facebook_user_id;
        $user->firstname = $socialize_user->user['first_name'];
        $user->lastname = $socialize_user->user['last_name'];
        $user->username = $socialize_user->name;
        $user->email = $socialize_user->email;
        $user->avatar = $socialize_user->avatar;
        $user->gender = $socialize_user->user['gender'];
        $user->provider = "facebook";
        $user->provider_id = "1";
        $user->access_token = $socialize_user->token;