- Added client_id field to StoreTenantRequest and UpdateTenantRequest for tenant management. - Updated TenantResource to include client_id in the response. - Created migration to establish clients table and link tenants to clients. - Migrated existing tenant integrations to client_integrations table. - Grouped specific tenants under a shared client (OnTicket) in a new migration. - Updated seeders to reflect new client structure and relationships. - Adjusted integration configurations to require client instead of tenant. - Added tests for client integration functionality and ensured existing tests reflect the new client structure.
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Integration\Requests;
|
|
|
|
use App\Domains\Integration\Models\Integration;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
class StoreClientIntegrationRequest extends FormRequest
|
|
{
|
|
protected ?Integration $integrationModel = null;
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$integrationCode = $this->route('integration_code');
|
|
$this->integrationModel = Integration::query()
|
|
->where('integration_code', $integrationCode)
|
|
->first();
|
|
|
|
if (! $this->integrationModel) {
|
|
throw ValidationException::withMessages([
|
|
'integration_code' => __('api.integration.not_configured'),
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$rules = [];
|
|
|
|
foreach ($this->integrationModel?->integration_data_schema ?? [] as $field => $rule) {
|
|
$rules['integration_data.'.$field] = $rule;
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
}
|