mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Eloquent;
|
|
|
|
/**
|
|
* Class ExpenseCategory.
|
|
*/
|
|
class LookupInvitation extends LookupModel
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'lookup_account_id',
|
|
'invitation_key',
|
|
'message_id',
|
|
];
|
|
|
|
public static function updateInvitation($accountKey, $invitation)
|
|
{
|
|
if (! env('MULTI_DB_ENABLED')) {
|
|
return;
|
|
}
|
|
|
|
if (! $invitation->message_id) {
|
|
return;
|
|
}
|
|
|
|
$current = config('database.default');
|
|
config(['database.default' => DB_NINJA_LOOKUP]);
|
|
|
|
$lookupAccount = LookupAccount::whereAccountKey($accountKey)
|
|
->firstOrFail();
|
|
|
|
$lookupInvitation = LookupInvitation::whereLookupAccountId($lookupAccount->id)
|
|
->whereInvitationKey($invitation->invitation_key)
|
|
->firstOrFail();
|
|
|
|
$lookupInvitation->message_id = $invitation->message_id;
|
|
$lookupInvitation->save();
|
|
|
|
config(['database.default' => $current]);
|
|
}
|
|
|
|
}
|