invoiceninja/app/Models/LookupUser.php

45 lines
938 B
PHP
Raw Normal View History

2017-04-30 20:08:49 +03:00
<?php
namespace App\Models;
use Eloquent;
2017-04-30 23:07:58 +03:00
use App\Models\User;
2017-04-30 20:08:49 +03:00
/**
* Class ExpenseCategory.
*/
2017-04-30 22:18:17 +03:00
class LookupUser extends LookupModel
2017-04-30 20:08:49 +03:00
{
/**
* @var array
*/
protected $fillable = [
'lookup_account_id',
'email',
2017-04-30 22:29:15 +03:00
'user_id',
2017-04-30 20:08:49 +03:00
];
2017-05-01 10:19:27 +03:00
public static function updateUser($accountKey, $userId, $email)
{
if (! env('MULTI_DB_ENABLED')) {
return;
}
$current = config('database.default');
config(['database.default' => DB_NINJA_LOOKUP]);
$lookupAccount = LookupAccount::whereAccountKey($accountKey)
->firstOrFail();
$lookupUser = LookupUser::whereLookupAccountId($lookupAccount->id)
->whereUserId($userId)
->firstOrFail();
$lookupUser->email = $email;
$lookupUser->save();
config(['database.default' => $current]);
}
2017-04-30 20:08:49 +03:00
}