示例#1
0
 public function live()
 {
     $firebase = new \Firebase\FirebaseLib(env('FIREBASE_URL'), env('FIREBASE_SECRET'));
     $online_users = json_decode($firebase->get('presence/'));
     $online = collect([]);
     if ($online_users != null) {
         foreach ($online_users as $key => $value) {
             if ($value) {
                 $user = User::find($key);
                 $online->push($user);
             }
         }
     }
     $users = User::count();
     $users_today = User::whereRaw('date(created_at) = curdate()')->count();
     return view('base.partials.live', compact('online', 'users_today', 'users'));
 }
示例#2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $users = User::get();
     return view('cms.winner.create', compact('users'));
 }
示例#3
0
 public function findOrCreateUser(Request $request, $fbUser)
 {
     if ($user = User::where('facebook_id', $fbUser->id)->first()) {
         // // Beginning of shit code from old site
         $query_string = 'ai_login_id=mdtn&ai_login_password=RcqwH#$7kA6H6MP3n&ai_command=auto_login&user_id=' . $user->apogee_id . '';
         // ////////////////////////////////////////
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, "https://www.prosperityalliance.com/service");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
         $result = curl_exec($ch);
         $string = $result;
         $status = preg_split('/&/', $string);
         if (isset($status[0])) {
             if ($status[0] == 'status=0') {
                 $status = preg_split('/=/', $status[2]);
                 if (isset($status[0])) {
                     $string2 = $result;
                     $string2 = preg_split('/&/', $string2);
                     $ai_sid_key = preg_split('/=/', $string2[2]);
                     //dd($ai_sid_key);
                     $ai_sid = preg_split('/=/', $string2[3]);
                     //dd($ai_sid);
                     Session::put('ai_sid_key', $ai_sid_key[1]);
                     Session::put('ai_sid', $ai_sid[1]);
                 }
             }
         }
         return $user;
     }
     $referred_by = 0;
     //dd($fbUser);
     if ($request->session()->has('referred_by')) {
         $referred_by = $request->session()->get('referred_by');
         $upstreamUser = User::where('apogee_id', $referred_by)->first();
         $upstreamUser->affiliates = $upstreamUser->affiliates + 1;
         $upstreamUser->save();
     }
     $banned_user = Ban::where('facebook_id', $fbUser->id)->first();
     if ($banned_user) {
         return "You have been banned.";
     }
     $random = substr(md5(rand()), 0, 4);
     $user = User::create(['username' => $fbUser->user['first_name'] . '' . $random, 'first_name' => $fbUser->user['first_name'], 'last_name' => $fbUser->user['last_name'], 'email' => $fbUser->email, 'phone' => null, 'facebook_id' => $fbUser->id, 'facebook_avatar' => $fbUser->avatar, 'referred_by' => $referred_by]);
     if ($fbUser->email) {
         $apUser = new ApogeeManager();
         $apUser->createUser($user);
         Mail::send('email.welcome', ['user' => $user], function ($m) use($user) {
             $m->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
             $m->to($user->email, $user->first_name)->subject('Important - About Your MDTN account.');
         });
         $client = new Client();
         $sendGridBody = ['email' => $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'userID' => strval($user->apogee_id), 'lead_id' => strval($user->referred_by), 'username' => $user->username];
         $res = $client->request('POST', 'https://api.sendgrid.com/v3/contactdb/recipients', ['headers' => ['Authorization' => 'Bearer ' . env('SENDGRID_API_KEY')], 'json' => [$sendGridBody]]);
         $body = json_decode($res->getBody()->getContents());
         $sendGridId = $body->persisted_recipients[0];
         $res2 = $client->request('POST', 'https://api.sendgrid.com/v3/contactdb/lists/167755/recipients/' . $sendGridId, ['headers' => ['Authorization' => 'Bearer ' . env('SENDGRID_API_KEY')]]);
     }
     return $user;
 }
示例#4
0
 public function team()
 {
     $affiliates = User::where('referred_by', Auth::user()->apogee_id)->get();
     return view('user.team', compact('affiliates'));
 }
示例#5
0
 public function admin($status, $userId)
 {
     $user = User::find($userId);
     if ($status == 'attach') {
         $user->roles()->attach('1');
         return redirect()->back()->withSuccess('Role successfully changed.');
     }
     $user->roles()->detach('1');
     return redirect()->back()->withSuccess('Role successfully changed.');
 }
示例#6
0
 public function ping(Request $request)
 {
     $req = json_decode($request);
     //dd($req);
     foreach ($req->messages as $message) {
         if ($message->type == 'membership') {
             $user = User::where('apogee_id', $message->data->user_id)->firstOrFail();
             switch ($message->data->status) {
                 case 'created':
                     $user->vip = 1;
                     $user->save();
                     break;
                 case 'deleted':
                     $user->vip = 0;
                     $user->save();
                 default:
                     $user->vip = 0;
                     $user->save();
                     break;
             }
         }
     }
 }