Пример #1
0
 public function freeCycle()
 {
     $card = $this->freeShuffle();
     $lid = $card->link_id;
     $directCount = $card->min_direct;
     $newCard = new static();
     $newCard->link_id = $lid;
     $newCard->min_direct = $directCount;
     $newCard->save();
     $cardline = new Cardline();
     $cardline->link_id = $lid;
     $newCard->cardpoints()->save($cardline);
     $this->deactivate($lid);
     // This will Broadcast To the Front End!
     $username = \App\Link::find($lid)->user->username;
     $data = ['event' => 'UserSignedUp', 'data' => ['username' => $username]];
     \PHPRedis::publish('rfn-chanel', json_encode($data));
 }
Пример #2
0
    return $rfnbonus;
});
//test route for broadcasting in the NewsBar
Route::get('sender', function () {
    $data = ['event' => 'UserSignedUp', 'data' => ['display_name' => 'chill', 'created_at' => '2011-12-17T09:24:17Z']];
    // Use this To Fire User Info In NewsBar
    // This Can Use the test-chanel in UserHasRegistered Event
    PHPRedis::publish('rfn-chanel', json_encode($data));
    return "User Signed Up!";
});
Route::get('receiver', function () {
    return view('receiver');
});
//test route for Redis set and get key
Route::get('message', function () {
    $app = PHPRedis::connection();
    $app->set("masterpowers", "Yeah Baby Yeah");
    print_r($app->get("masterpowers"));
});
// Route For Searching For a Sponsor Thru Ajax
Route::post('searchUser', 'SearchController@searchUser');
// Route For AutoComplete
Route::get('search/autocomplete', 'SearchController@autocomplete');
// For For Activating First Link note User Must Be Auth! Tweak it if Dash is OK!
Route::get('activate/FirstLink', ['as' => 'get1stlink', 'uses' => 'CodeController@showActivateFirstLink']);
Route::post('activate/FirstLink', ['as' => '1stlinkactivation', 'uses' => 'CodeController@activateFirstLink']);
// after first link is activated dont show anymore this url to them
Route::post('signup', ['as' => 'signup', 'uses' => 'Auth\\AuthController@create']);
// Route::get('{link?}', ['as' => 'links', 'uses' => 'LinkController@getRefLink']);
Route::get('activeSponsor/{id}', function ($id) {
    $id = App\Link::where('id', $id)->firstOrFail()->activeSponsor($id);
Пример #3
0
 public function create(Request $request)
 {
     $createUserRequest = new CreateUserRequest();
     $validator = Validator::make($request->all(), $createUserRequest->rules(), $createUserRequest->messages());
     // Validate Form
     if ($validator->fails()) {
         return response()->json(['success' => false, 'errors' => $validator->errors()->toArray()], 400);
     }
     // Check Captcha still Valid or Used!
     if ($this->captchaCheck() == false) {
         $errors = ['captchaError' => trans('auth.captchaError')];
         return response()->json(['success' => false, 'errors' => $errors], 400);
     }
     // Check Sponsor Cookie , Provide One if None
     if (\Cookie::get('sponsor') == false) {
         $link = Link::with('user', 'user.profile')->where('link', $request->sponsor_link)->first();
         $cookie = $link->toArray();
         $errors = ['CookieError' => trans('auth.cookieError'), 'cookieNew' => trans('auth.cookieAttached')];
         return response()->json(['success' => false, 'errors' => $errors], 400)->withCookie(\Cookie::forever('sponsor', $cookie));
     }
     // This Will Prevent Unnecessary Creation of Account if Something Failed!
     DB::beginTransaction();
     $user = User::create($request->all());
     $profile = $user->profile()->create($request->all());
     $link = new Link();
     $link->link = Input::get('username');
     $user->links()->save($link);
     // IF Error Occured Throw an Exception then Rollback!
     try {
         if (!$user && !$profile && !$link) {
             throw new \Exception('Account Creation Failed ,Account is Rollback');
         }
     } catch (\Exception $e) {
         DB::rollback();
         $errors = ['ExceptionError' => $e->getMessage(), 'RefreshPage' => trans('auth.refreshPage')];
         return response()->json(['success' => false, 'errors' => $errors], 400);
         // Failed Creation
     }
     // Account Successfully Created
     DB::commit();
     // Send Email To The New User
     $this->mail->registered($user);
     $data = ['event' => 'UserSignedUp', 'data' => ['display_name' => $profile->display_name, 'created_at' => $user->created_at]];
     // BroadCast Realtime in NewsBar
     \PHPRedis::publish('rfn-chanel', json_encode($data));
     // Forget the Set Cookie
     $cookie = \Cookie::forget('sponsor');
     // Return With a Response to Delete Cookie
     return response()->json(['success' => true], 201)->withCookie($cookie);
 }