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:42:55 +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
|
|
|
}
|