You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.5 KiB
63 lines
1.5 KiB
<?php
|
|
|
|
use App\Domains\Finance\Actions\PaymentProcessing\InitializeInvoice;
|
|
use App\Livewire\Concerns\WithModal;
|
|
use App\Livewire\Concerns\WithToast;
|
|
use App\Livewire\Forms\Finance\InvoiceForm;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\Locked;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
|
|
new class extends Component
|
|
{
|
|
use WithModal;
|
|
use WithToast;
|
|
|
|
#[Locked]
|
|
public ?string $id = null;
|
|
|
|
#[Locked]
|
|
public string $mode = 'create';
|
|
|
|
public InvoiceForm $form;
|
|
|
|
protected string $resourceName = 'invoice';
|
|
|
|
public function show(int|string $id): void
|
|
{
|
|
$this->id = $id;
|
|
$this->mode = 'update';
|
|
// $this->form->fill($this->model->only(['name']));
|
|
}
|
|
|
|
#[Computed]
|
|
public function invoiceSchema(): array
|
|
{
|
|
|
|
return $this->form
|
|
->type
|
|
?->schema()
|
|
->withContext([
|
|
'faculty' => $this->form->detail['faculty'] ?? null,
|
|
])
|
|
->withFormString('form.detail.')
|
|
->getSchema() ?? [];
|
|
}
|
|
|
|
public function save(InitializeInvoice $initializeInvoice): void
|
|
{
|
|
$this->form->validate();
|
|
$initializeInvoice->execute($this->form->toDto());
|
|
|
|
$this->dispatch('hide-invoice-form-modal');
|
|
$this->js("LaravelDataTables['invoice-table'].ajax.reload(null, false)");
|
|
}
|
|
|
|
public function hide(): void
|
|
{
|
|
$this->form->reset();
|
|
$this->reset('id', 'mode');
|
|
$this->resetErrorBag();
|
|
}
|
|
};
|
|
|