mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 07:04:35 -04:00
Set locale from query parameter
This commit is contained in:
parent
69eecbf281
commit
3bcb65efc2
@ -15,16 +15,36 @@ namespace App\Http\Controllers\ClientPortal;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\BillingSubscription;
|
use App\Models\BillingSubscription;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class BillingSubscriptionPurchaseController extends Controller
|
class BillingSubscriptionPurchaseController extends Controller
|
||||||
{
|
{
|
||||||
public function index(BillingSubscription $billing_subscription)
|
public function index(BillingSubscription $billing_subscription, Request $request)
|
||||||
{
|
{
|
||||||
|
if ($request->has('locale')) {
|
||||||
|
$this->setLocale($request->query('locale'));
|
||||||
|
}
|
||||||
|
|
||||||
return view('billing-portal.purchase', [
|
return view('billing-portal.purchase', [
|
||||||
'billing_subscription' => $billing_subscription,
|
'billing_subscription' => $billing_subscription,
|
||||||
'hash' => Str::uuid()->toString(),
|
'hash' => Str::uuid()->toString(),
|
||||||
|
'request_data' => $request->all(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set locale for incoming request.
|
||||||
|
*
|
||||||
|
* @param string $locale
|
||||||
|
*/
|
||||||
|
private function setLocale(string $locale): void
|
||||||
|
{
|
||||||
|
$record = DB::table('languages')->where('locale', $locale)->first();
|
||||||
|
|
||||||
|
if ($record) {
|
||||||
|
App::setLocale($record->locale);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,13 @@ class BillingPortalPurchase extends Component
|
|||||||
*/
|
*/
|
||||||
public $quantity = 1;
|
public $quantity = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First-hit request data (queries, locales...).
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $request_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle user authentication
|
* Handle user authentication
|
||||||
*
|
*
|
||||||
@ -246,8 +253,6 @@ class BillingPortalPurchase extends Component
|
|||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
];
|
];
|
||||||
|
|
||||||
dd($data);
|
|
||||||
|
|
||||||
$this->invoice = $this->billing_subscription
|
$this->invoice = $this->billing_subscription
|
||||||
->service()
|
->service()
|
||||||
->createInvoice($data)
|
->createInvoice($data)
|
||||||
@ -290,7 +295,7 @@ class BillingPortalPurchase extends Component
|
|||||||
return $this->quantity;
|
return $this->quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: David for review.
|
// TODO: Dave review.
|
||||||
if ($this->quantity >= $this->billing_subscription->max_seats_limit) {
|
if ($this->quantity >= $this->billing_subscription->max_seats_limit) {
|
||||||
return $this->quantity;
|
return $this->quantity;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
@section('meta_title', $billing_subscription->product->product_key)
|
@section('meta_title', $billing_subscription->product->product_key)
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
@livewire('billing-portal-purchase', ['billing_subscription' => $billing_subscription, 'contact' => auth('contact')->user(), 'hash' => $hash])
|
@livewire('billing-portal-purchase', ['billing_subscription' => $billing_subscription, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data])
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@push('footer')
|
@push('footer')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user