DB_NINJA_1]); $this->forceMigrate(); } private function forceMigrate() { $data = []; $company = Company::on(DB_NINJA_1) ->whereNull('plan') ->orWhereIn('plan', ['','free']) ->whereHas('accounts', function ($query){ $query->where('account_key', 'NOT LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%'); }) ->with('accounts') ->withCount('accounts') ->having('accounts_count', '>=', 1) ->first(); $user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first(); $db = DB_NINJA_1; if($company){ foreach($company->accounts as $key => $account) { $data['companies'][$key]['id'] = $account->id; } $this->dispatch(new HostedMigration($user, $data, $db, true)); $company->is_migrated = true; $company->save(); } } }