2017-04-30 19:08:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Eloquent;
|
2017-04-30 22:07:58 +02:00
|
|
|
use App\Models\User;
|
2017-04-30 19:08:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ExpenseCategory.
|
|
|
|
*/
|
2017-04-30 21:18:17 +02:00
|
|
|
class LookupUser extends LookupModel
|
2017-04-30 19:08:49 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'lookup_account_id',
|
|
|
|
'email',
|
2017-04-30 21:29:15 +02:00
|
|
|
'user_id',
|
2017-04-30 19:08:49 +02:00
|
|
|
];
|
|
|
|
|
2017-05-01 16:29:31 +02:00
|
|
|
public static function updateUser($accountKey, $userId, $email, $confirmationCode)
|
2017-05-01 09:19:27 +02:00
|
|
|
{
|
|
|
|
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;
|
2017-05-01 16:29:31 +02:00
|
|
|
$lookupUser->confirmation_code = $confirmationCode;
|
2017-05-01 09:19:27 +02:00
|
|
|
$lookupUser->save();
|
|
|
|
|
|
|
|
config(['database.default' => $current]);
|
|
|
|
}
|
|
|
|
|
2017-04-30 19:08:49 +02:00
|
|
|
}
|