42 lines
1018 B
PHP
42 lines
1018 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Livewire\Forms;
|
|
|
|
use App\Data\ConnectService\ConnectServiceData;
|
|
use App\Services\ConnectedServicesService;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Form;
|
|
|
|
class StoreConnectedAppFrom extends Form
|
|
{
|
|
#[Validate('required|string|max:255|min:3')]
|
|
public string $name = '';
|
|
|
|
#[Validate('required|numeric|min:1')]
|
|
public int $providerId = 0;
|
|
|
|
#[Validate('required|numeric|min:1')]
|
|
public int $protocolId = 0;
|
|
|
|
#[Validate('nullable|string|max:255|min:3')]
|
|
public ?string $logoUrl = null;
|
|
|
|
public function save(): void
|
|
{
|
|
$this->validate();
|
|
|
|
$serviceData = new ConnectServiceData(
|
|
name: $this->name,
|
|
serviceProviderId: $this->providerId,
|
|
serviceProtocolId: $this->protocolId,
|
|
logoUrl: $this->logoUrl,
|
|
slug: str($this->name)->slug()->toString(),
|
|
);
|
|
|
|
app(ConnectedServicesService::class)->create($serviceData);
|
|
$this->reset();
|
|
}
|
|
}
|