fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -14,6 +14,10 @@ use Illuminate\Validation\ValidationException;
|
||||
/** Reuse the CRM master without manufacturing an interest, lead or consent. */
|
||||
class OpportunityContacts
|
||||
{
|
||||
/**
|
||||
* @param array<array-key, mixed> $input
|
||||
* @return array<array-key, mixed>
|
||||
*/
|
||||
public function save(User $actor, int $id, array $input): array
|
||||
{
|
||||
$access = app(PortalProfileAccess::class);
|
||||
@@ -63,7 +67,7 @@ class OpportunityContacts
|
||||
$investors = Investor::where('organization_id', $record->organization_id)->whereIn('status', ['prospect', 'active'])->lockForUpdate()->get();
|
||||
if (! empty($data['investor_id'])) {
|
||||
$investor = $investors->firstWhere('id', $data['investor_id']);
|
||||
abort_unless($investor, 403, 'O cadastro selecionado não pertence ao promotor desta oportunidade.');
|
||||
abort_unless($investor !== null, 403, 'O cadastro selecionado não pertence ao promotor desta oportunidade.');
|
||||
} elseif ($investors->count() === 1) {
|
||||
$investor = $investors->first();
|
||||
} elseif ($investors->count() > 1) {
|
||||
@@ -73,7 +77,7 @@ class OpportunityContacts
|
||||
throw ValidationException::withMessages(['investor_type' => 'Indique a classificação do promotor no cadastro existente.']);
|
||||
}
|
||||
$organization = DB::table('organizations')->where('id', $record->organization_id)->whereNull('deleted_at')->first();
|
||||
abort_unless($organization, 422, 'Organização indisponível.');
|
||||
abort_unless($organization !== null, 422, 'Organização indisponível.');
|
||||
$investor = new Investor;
|
||||
PortalAudit::save($investor, ['organization_id' => $organization->id, 'legal_name' => $organization->name,
|
||||
'investor_type' => $data['investor_type'], 'status' => 'prospect', 'source_system' => 'portal-promoter-master',
|
||||
|
||||
Reference in New Issue
Block a user