public function getInvitee($username) { $lender = LenderQuery::create()->useUserQuery()->filterByUsername($username)->endUse()->findOne(); $lenderInviteVisit = InviteVisitQuery::create()->findOneById(Session::get('lenderInviteVisitId')); if (!$lender) { return Redirect::route('/'); } $ycAccountCredit = TransactionQuery::create()->filterByUserId(Setting::get('site.YCAccountId'))->getTotalBalance(); if ($ycAccountCredit->getAmount() < 5000) { return View::make('lender.invite-inactive'); } if (!Auth::check()) { $lenderInvite = $shareType = null; if (Request::query('h')) { $lenderInvite = InviteQuery::create()->filterByLender($lender)->findOneByHash(Request::query('h')); $shareType = $lenderInvite ? 1 : null; } else { $shareType = Request::query('s') ?: 0; } $isNewVisit = !$lenderInviteVisit || $lenderInviteVisit->getLenderId() != $lender->getId(); if ($isNewVisit && $shareType !== null) { $lenderInviteVisit = $this->lenderService->addLenderInviteVisit($lender, $shareType, $lenderInvite); Session::put('lenderInviteVisitId', $lenderInviteVisit->getId()); return Redirect::route('lender:invitee', ['username' => $lender->getUser()->getUsername()]); } } return View::make('lender.invitee', compact('lender')); }
protected function join(Lender $user) { if (Session::get('lenderInviteVisitId')) { $lenderInviteVisit = InviteVisitQuery::create()->findOneById(Session::get('lenderInviteVisitId')); $inviter = $lenderInviteVisit->getLender()->getUser(); $this->lenderService->processLenderInvite($user, $lenderInviteVisit); Session::forget('lenderInviteVisitId'); Flash::modal(View::make('lender.invite-new-account', compact('inviter'))->render()); } else { Flash::success(\Lang::get('comments.flash.welcome')); } Auth::login($user->getUser()); return Redirect::route('lender:dashboard'); }