guard('contact')->user() && auth()->guard('contact')->user()->company_id != $subscription->company_id) { auth()->guard('contact')->logout(); $request->session()->invalidate(); } if ($request->has('locale')) { $this->setLocale($request->query('locale')); } return view('billing-portal.purchase', [ 'subscription' => $subscription, 'hash' => Str::uuid()->toString(), 'request_data' => $request->all(), ]); } public function upgrade(Subscription $subscription, Request $request) { /* Make sure the contact is logged into the correct company for this subscription */ if (auth()->guard('contact')->user() && auth()->guard('contact')->user()->company_id != $subscription->company_id) { auth()->guard('contact')->logout(); $request->session()->invalidate(); } if ($request->has('locale')) { $this->setLocale($request->query('locale')); } return view('billing-portal.purchasev2', [ 'subscription' => $subscription, 'hash' => Str::uuid()->toString(), 'request_data' => $request->all(), ]); } /** * Set locale for incoming request. * * @param string $locale */ private function setLocale(string $locale): void { $record = Cache::get('languages')->filter(function ($item) use ($locale) { return $item->locale == $locale; })->first(); if ($record) { App::setLocale($record->locale); } } }