belongsTo('App\Models\LookupAccount'); } public static function createNew($accountKey, $data) { if (! env('MULTI_DB_ENABLED')) { return; } $current = config('database.default'); config(['database.default' => DB_NINJA_LOOKUP]); $lookupAccount = LookupAccount::whereAccountKey($accountKey)->first(); if ($lookupAccount) { $data['lookup_account_id'] = $lookupAccount->id; } else { abort('Lookup account not found for ' . $accountKey); } static::create($data); config(['database.default' => $current]); } public function getDbServer() { return $this->lookupAccount->lookupCompany->dbServer->name; } }