Ejemplo n.º 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));
 }
Ejemplo n.º 2
0
});
Route::get('fire', function () {
    // this fires the event
    event(new App\Events\IncreaseRfnBonus());
    return "Event Fired!";
});
Route::get('api/rfnbonus', function () {
    $rfnbonus = App\User::all()->count() * 5;
    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');
Ejemplo n.º 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);
 }