major update
This commit is contained in:
@@ -10,7 +10,12 @@ class TenantCustomFieldService
|
||||
{
|
||||
private const ALLOWED_TYPES = ['text', 'textarea', 'select', 'multiselect', 'boolean', 'date'];
|
||||
|
||||
public static function listForTenant(int $tenantId): array
|
||||
public function __construct(
|
||||
private readonly TenantRepository $tenantRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function listForTenant(int $tenantId): array
|
||||
{
|
||||
$tenantId = (int) $tenantId;
|
||||
if ($tenantId <= 0) {
|
||||
@@ -44,9 +49,9 @@ class TenantCustomFieldService
|
||||
return $definitions;
|
||||
}
|
||||
|
||||
public static function createForTenant(int $tenantId, array $input, int $currentUserId): array
|
||||
public function createForTenant(int $tenantId, array $input, int $currentUserId): array
|
||||
{
|
||||
if ($tenantId <= 0 || !(new TenantRepository())->find($tenantId)) {
|
||||
if ($tenantId <= 0 || !$this->tenantRepository->find($tenantId)) {
|
||||
return ['ok' => false, 'errors' => [t('Tenant not found')]];
|
||||
}
|
||||
|
||||
@@ -85,7 +90,7 @@ class TenantCustomFieldService
|
||||
return ['ok' => true, 'id' => (int) $definitionId, 'form' => $form];
|
||||
}
|
||||
|
||||
public static function updateByUuid(string $uuid, array $input, int $currentUserId): array
|
||||
public function updateByUuid(string $uuid, array $input, int $currentUserId): array
|
||||
{
|
||||
$uuid = trim($uuid);
|
||||
if ($uuid === '') {
|
||||
@@ -133,7 +138,7 @@ class TenantCustomFieldService
|
||||
return ['ok' => true, 'form' => $form];
|
||||
}
|
||||
|
||||
public static function deleteByUuid(string $uuid): array
|
||||
public function deleteByUuid(string $uuid): array
|
||||
{
|
||||
$uuid = trim($uuid);
|
||||
if ($uuid === '') {
|
||||
@@ -150,7 +155,7 @@ class TenantCustomFieldService
|
||||
return ['ok' => true, 'definition' => $existing];
|
||||
}
|
||||
|
||||
public static function definitionTenantIdByUuid(string $uuid): int
|
||||
public function definitionTenantIdByUuid(string $uuid): int
|
||||
{
|
||||
$definition = TenantCustomFieldDefinitionRepository::findByUuid(trim($uuid));
|
||||
return (int) ($definition['tenant_id'] ?? 0);
|
||||
|
||||
Reference in New Issue
Block a user