1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00
invoiceninja/app/Models/LookupInvitation.php
2019-01-30 22:25:37 +11:00

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]);
}
}