delete(); // Delete the account if it already exists $account = Account::withoutGlobalScopes() ->where('username', $username) ->where('domain', $domain) ->first(); if ($account) { // We don't have foreign keys yet… $account->admin()->delete(); $account->delete(); } $account = new Account; $account->username = $username; $account->domain = $domain; $account->email = 'admin_test@sip.example.org'; $account->activated = true; $account->user_agent = 'Test'; $account->ip_address = '0.0.0.0'; // Create an "old" account to prevent unwanted deletion on the test server $account->creation_time = Carbon::now()->subYears(3); $account->save(); $admin = new Admin; $admin->account_id = $account->id; $admin->save(); $apiKey = new ApiKey; $apiKey->account_id = $account->id; $apiKey->key = $secret; $apiKey->save(); $this->info('Admin test account created: "sip:' . $username . '@' . $domain . '" | API Key: "' . $secret . '"'); return 0; } }