- Renamed `ConnectedServicesService` to `ConnectedAppService` and adjusted related factories, DTOs, and forms. - Introduced `ConnectionProtocolService` and `ConnectionProviderService` for managing protocols and providers. - Updated Livewire forms to improve validation and allow real-time provider searches. - Added a `ConnectionStatus` field and related dropdown to service connection forms. - Enhanced form handling with new services, search functionality, and validation rules. - Refactored factory and DTO structure for better consistency and modularity. - Added service layer documentation and streamlined component data mappings.
35 lines
997 B
PHP
35 lines
997 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Factories;
|
|
|
|
use App\Data\ConnectedApp\ConnectAppRequest;
|
|
use App\Enums\ConnectionStatusEnum;
|
|
use App\Models\ConnectionStatus;
|
|
|
|
final class ConnectedAppFactory
|
|
{
|
|
public function createDataFromDto(ConnectAppRequest $data): array
|
|
{
|
|
$result = [
|
|
'name' => $data->name,
|
|
'connection_provider_id' => $data->connectionProviderId,
|
|
'connection_protocol_id' => $data->connectionProtocolId,
|
|
'logo_url' => $data->logoUrl,
|
|
'slug' => $data->slug,
|
|
'connection_status_id' => $data->statusId,
|
|
];
|
|
|
|
// Check if the staus is filled, if not select disconnected by default
|
|
if (null === $data->statusId) {
|
|
$status = ConnectionStatus::query()
|
|
->where('name', '=', ConnectionStatusEnum::Disconnected->value)
|
|
->pluck('id');
|
|
$result['service_status_id'] = $status[0];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|