mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for check data script
This commit is contained in:
parent
527b81768a
commit
3c76bfa90c
@ -448,13 +448,23 @@ class CheckData extends Command
|
|||||||
//check contact exists!
|
//check contact exists!
|
||||||
if($contact_class::where('company_id', $entity->company_id)->where($client_vendor_key,$entity->{$client_vendor_key})->exists())
|
if($contact_class::where('company_id', $entity->company_id)->where($client_vendor_key,$entity->{$client_vendor_key})->exists())
|
||||||
{
|
{
|
||||||
$invitation = new $entity_obj();
|
|
||||||
$invitation->company_id = $entity->company_id;
|
$contact = $contact_class::where('company_id', $entity->company_id)->where($client_vendor_key,$entity->{$client_vendor_key})->first();
|
||||||
$invitation->user_id = $entity->user_id;
|
|
||||||
$invitation->{$entity_key} = $entity->id;
|
//double check if an archived invite exists
|
||||||
$invitation->{$contact_id} = $contact_class::where('company_id', $entity->company_id)->where($client_vendor_key,$entity->{$client_vendor_key})->first()->id;
|
if($contact && $entity->invitations()->withTrashed()->where($contact_id, $contact->id)->count() != 0) {
|
||||||
$invitation->key = Str::random(config('ninja.key_length'));
|
$i = $entity->invitations()->withTrashed()->where($contact_id, $contact->id)->first();
|
||||||
$this->logMessage("Add invitation for {$entity_key} - {$entity->id}");
|
$i->restore();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$invitation = new $entity_obj();
|
||||||
|
$invitation->company_id = $entity->company_id;
|
||||||
|
$invitation->user_id = $entity->user_id;
|
||||||
|
$invitation->{$entity_key} = $entity->id;
|
||||||
|
$invitation->{$contact_id} = $contact->id;
|
||||||
|
$invitation->key = Str::random(config('ninja.key_length'));
|
||||||
|
$this->logMessage("Add invitation for {$entity_key} - {$entity->id}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
|
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user