/** * личный кабинет * * @return \Illuminate\View\View */ public function index() { if (Input::get('orderNumber')) { return Redirect::to('/account'); } Customer::instance()->closeIfNotMember(); $promo = null; $mainPage = Config::get('app.url'); $langReplace = App::getLocale() == 'ru' ? 'index' : App::getLocale(); $mainPage = str_replace('#lang#', $langReplace, $mainPage); try { $api = new Api(); if (!$api->key()) { return \Redirect::to($mainPage); } $user = $api->ContrInfo(); $promo = $this->promoInfo($user, $promo); //$token = PaymentCloud::getToken($user['id']); $agbisKey = $api->key(); $customer = Customer::instance()->initByExternalId($user['id']); if (!$customer->get()) { Reporter::errorLostExternalCustomer($user['id'], $user); $customer->cleanup(); $api->cleanup(); return \Redirect::to($mainPage); } $saveCard = $customer->isSaveCard(); $cards = PaymentCloud::getCustomersCards($api->id()); } catch (ApiException $e) { return \Redirect::to($mainPage); } $invite = new InviteComponent(); return View::make('ac::index', ['user' => $user, 'promo' => $promo, 'agbisKey' => $agbisKey, 'saveCard' => $saveCard, 'invite_url' => $invite->url(), 'cards' => $cards]); }