mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Add Purchase component to BillingPortal
This commit is contained in:
parent
b290969ccf
commit
2c1cb88783
77
app/Livewire/BillingPortal/Purchase.php
Normal file
77
app/Livewire/BillingPortal/Purchase.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\BillingPortal;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Subscription;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class Purchase extends Component
|
||||
{
|
||||
public Subscription $subscription;
|
||||
|
||||
public string $db;
|
||||
|
||||
public int $step = 0;
|
||||
|
||||
public array $steps = [
|
||||
Setup::class,
|
||||
Authentication::class,
|
||||
RFF::class,
|
||||
Example::class,
|
||||
];
|
||||
|
||||
public array $context = [];
|
||||
|
||||
#[On('purchase.context')]
|
||||
public function handleContext(string $property, $value): void
|
||||
{
|
||||
$this->context[$property] = $value;
|
||||
}
|
||||
|
||||
#[On('purchase.next')]
|
||||
public function handleNext(): void
|
||||
{
|
||||
if ($this->step < count($this->steps) - 1) {
|
||||
$this->step++;
|
||||
}
|
||||
}
|
||||
|
||||
#[On('purchase.forward')]
|
||||
public function handleForward(string $component): void
|
||||
{
|
||||
$this->step = array_search($component, $this->steps);
|
||||
}
|
||||
|
||||
#[Computed()]
|
||||
public function component(): string
|
||||
{
|
||||
return $this->steps[$this->step];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$this->context = [
|
||||
'quantity' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('billing-portal.v3.purchase');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user