1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Models/LookupInvitation.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2017-04-30 19:08:49 +02:00
<?php
namespace App\Models;
use Eloquent;
/**
* Class ExpenseCategory.
*/
2017-04-30 21:18:17 +02:00
class LookupInvitation extends LookupModel
2017-04-30 19:08:49 +02:00
{
/**
* @var array
*/
protected $fillable = [
'lookup_account_id',
'invitation_key',
'message_id',
];
2017-06-18 13:43:56 +02:00
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]);
}
2017-04-30 19:08:49 +02:00
}