@@ -48,7 +48,16 @@ class OrganizationConfiguration
|
||||
throw ValidationException::withMessages(['version' => 'A parametrização foi alterada. Actualize e compare antes de guardar.']);
|
||||
}
|
||||
$before = null;
|
||||
if ($command === 'profile') {
|
||||
if ($command === 'company_details') {
|
||||
abort_unless(Schema::hasColumn('tenants', 'company_details'), 503, 'Instalação dos dados da empresa pendente.');
|
||||
if (count(array_filter($data['establishments'], fn (array $row) => $row['kind'] === 'headquarters')) > 1) {
|
||||
throw ValidationException::withMessages(['establishments' => 'Identifique apenas um estabelecimento como sede.']);
|
||||
}
|
||||
$company = Tenant::query()->findOrFail($actor->tenant_id);
|
||||
$before = $company->only(['company_details']);
|
||||
$company->update(['company_details' => array_intersect_key($data, CompanyDetails::FIELDS + ['bank_accounts' => true, 'establishments' => true])]);
|
||||
$after = [...$company->only(['company_details']), 'reason' => $data['reason']];
|
||||
} elseif ($command === 'profile') {
|
||||
$profile = isset($data['id']) ? DB::table('organization_profiles')->where('tenant_id', $actor->tenant_id)->where('id', $data['id'])->first() : null;
|
||||
abort_if(isset($data['id']) && ! $profile, 404);
|
||||
if ($profile && in_array('admin', $data['permissions'], true) && DB::table('organization_memberships')->where('tenant_id', $actor->tenant_id)->where('profile_id', $profile->id)->where('maintenance', true)->exists()) {
|
||||
|
||||
Reference in New Issue
Block a user