Aplikasi Keuangan yang mengatur lalu lintas transaksi antara bank dan aplikasi internal Kampus
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.
 
 
 
 
 

73 lines
1.9 KiB

<?php
use App\Domains\Channel\Actions\AppProvisioning\ProvisionConsumerApp;
use App\Domains\Channel\DTOs\AppProvisioning\ProvisionConsumerAppDTO;
use App\Domains\Channel\Models\Client;
use App\Livewire\Concerns\WithModal;
use App\Livewire\Concerns\WithToast;
use App\Livewire\Forms\Channel\ClientForm;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Locked;
use Livewire\Component;
new class extends Component
{
use WithModal;
use WithToast;
#[Locked]
public ?string $id = null;
#[Locked]
public string $mode = 'create';
public ClientForm $form;
protected string $resourceName = 'client';
public function save(ProvisionConsumerApp $create): void
{
$this->form->validate();
if ($this->mode === 'create') {
$create->execute(new ProvisionConsumerAppDTO(
name: $this->form->name,
code: $this->form->code,
url: $this->form->url,
));
} elseif ($this->mode === 'update') {
$this->client->update([
'name' => $this->form->name,
'code' => $this->form->code,
'url' => $this->form->url,
]);
}
$this->success($this->message);
$this->dispatch('hide-client-form-modal');
$this->js("LaravelDataTables['client-table'].ajax.reload(null, false)");
$this->form->reset();
$this->form->resetValidation();
$this->reset('id', 'mode');
}
#[Computed]
public function client(): ?Client
{
return $this->id ? Client::where('ulid', $this->id)->first() : null;
}
public function show(int|string $id): void
{
$this->id = $id;
$this->mode = 'update';
$this->form->fill($this->client->only(['name', 'code', 'url']));
}
public function hide(): void
{
$this->form->reset();
$this->form->resetValidation();
$this->reset('id', 'mode');
}
};