- Added `Choices` component for dropdowns with search and multi-selection functionality. - Implemented foundational classes for service connection: - `ConnectServiceData` - `ConnectedServiceFactory` - `ConnectedServicesService` - Added `ConnectServiceForm` Livewire component for managing service connections. - Introduced shared utility traits (`HasAttributeHelpers`) and error components. - Added components for generic use: `Input` and `ListItem`.
42 lines
1015 B
PHP
42 lines
1015 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 ConnectServiceFrom 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();
|
|
}
|
|
}
|