- Added `ConnectionStatusData` DTO and `ConnectionStatusService` for managing connection statuses with mapped enums. - Updated `ConnectedAppFactory` and Livewire `StoreConnectedAppForm` to integrate `ConnectionStatusData` and remove `logoUrl` field. - Adjusted `ConnectedApp` model to rename columns for consistency. - Implemented error handling in `ConnectedAppService::create()` for improved resilience. - Updated Blade templates and composer dependencies for compatibility.
34 lines
955 B
PHP
34 lines
955 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,
|
|
'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;
|
|
}
|
|
}
|