mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 23:50:33 +00:00
27 lines
564 B
PHP
27 lines
564 B
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api;
|
|
|
|
use App\Models\ApiKey;
|
|
|
|
trait ApiKeysTrait
|
|
{
|
|
public function getApiKey()
|
|
{
|
|
$findApiKey = ApiKey::where('name', 'Unit Test API')->first();
|
|
if ($findApiKey) {
|
|
return $findApiKey;
|
|
}
|
|
$this->createApiKey();
|
|
return $this->getApiKey();
|
|
}
|
|
|
|
public function createApiKey()
|
|
{
|
|
$apiKey = new ApiKey();
|
|
$apiKey->name = 'Unit Test API';
|
|
$apiKey->is_active = true;
|
|
$apiKey->enable_whitelisted_ips = false;
|
|
$apiKey->save();
|
|
}
|
|
}
|