2021-03-11 14:05:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\BillingSubscription;
|
|
|
|
use Illuminate\Http\Request;
|
2021-03-18 15:41:26 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2021-03-22 14:09:29 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2021-03-18 15:41:26 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2021-03-15 17:33:27 +01:00
|
|
|
use Illuminate\Support\Str;
|
2021-03-11 14:05:23 +01:00
|
|
|
|
|
|
|
class BillingSubscriptionPurchaseController extends Controller
|
|
|
|
{
|
2021-03-18 15:41:26 +01:00
|
|
|
public function index(BillingSubscription $billing_subscription, Request $request)
|
2021-03-11 14:05:23 +01:00
|
|
|
{
|
2021-03-18 15:41:26 +01:00
|
|
|
if ($request->has('locale')) {
|
|
|
|
$this->setLocale($request->query('locale'));
|
|
|
|
}
|
|
|
|
|
2021-03-15 17:33:27 +01:00
|
|
|
return view('billing-portal.purchase', [
|
|
|
|
'billing_subscription' => $billing_subscription,
|
|
|
|
'hash' => Str::uuid()->toString(),
|
2021-03-18 15:41:26 +01:00
|
|
|
'request_data' => $request->all(),
|
2021-03-15 17:33:27 +01:00
|
|
|
]);
|
2021-03-11 14:05:23 +01:00
|
|
|
}
|
2021-03-18 15:41:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set locale for incoming request.
|
|
|
|
*
|
|
|
|
* @param string $locale
|
|
|
|
*/
|
|
|
|
private function setLocale(string $locale): void
|
|
|
|
{
|
2021-03-22 14:09:29 +01:00
|
|
|
$record = Cache::get('languages')->filter(function ($item) use ($locale) {
|
|
|
|
return $item->locale == $locale;
|
|
|
|
})->first();
|
2021-03-18 15:41:26 +01:00
|
|
|
|
|
|
|
if ($record) {
|
|
|
|
App::setLocale($record->locale);
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 14:05:23 +01:00
|
|
|
}
|