feat: prepare private offers through existing opportunities
This commit is contained in:
@@ -14,6 +14,19 @@ use Illuminate\Validation\ValidationException;
|
||||
/** Reuse the CRM master without manufacturing an interest, lead or consent. */
|
||||
class OpportunityContacts
|
||||
{
|
||||
public function related(Opportunity $record, string $id): bool
|
||||
{
|
||||
$contacts = DB::table('contacts')->where('contacts.id', $id)->whereNull('contacts.deleted_at');
|
||||
if ($record->organization_id) {
|
||||
$contacts->whereExists(fn ($q) => $q->selectRaw('1')->from('investor_contacts as ic')->join('investors as i', 'i.id', '=', 'ic.investor_id')
|
||||
->whereColumn('ic.contact_id', 'contacts.id')->where('i.organization_id', $record->organization_id)->whereNull('i.deleted_at'));
|
||||
} else {
|
||||
$contacts->where('source_system', 'portal-user-contact')->where('external_id', 'user:'.$record->owner_user_id);
|
||||
}
|
||||
|
||||
return $contacts->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key, mixed> $input
|
||||
* @return array<array-key, mixed>
|
||||
|
||||
Reference in New Issue
Block a user