Update location and databasehost services to use repositories
Includes unit tests for both services
This commit is contained in:
parent
5c3dc60d1e
commit
50588a1f54
10 changed files with 564 additions and 68 deletions
|
@ -24,6 +24,7 @@
|
|||
|
||||
namespace Pterodactyl\Extensions;
|
||||
|
||||
use Pterodactyl\Contracts\Repository\DatabaseHostInterface;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Illuminate\Config\Repository as ConfigRepository;
|
||||
|
@ -45,25 +46,25 @@ class DynamicDatabaseConnection
|
|||
protected $encrypter;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Models\DatabaseHost
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostInterface
|
||||
*/
|
||||
protected $model;
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* DynamicDatabaseConnection constructor.
|
||||
*
|
||||
* @param \Illuminate\Config\Repository $config
|
||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||
* @param \Illuminate\Config\Repository $config
|
||||
* @param \Pterodactyl\Contracts\Repository\DatabaseHostInterface $repository
|
||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigRepository $config,
|
||||
Encrypter $encrypter,
|
||||
DatabaseHost $model
|
||||
DatabaseHostInterface $repository,
|
||||
Encrypter $encrypter
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->model = $model;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +77,7 @@ class DynamicDatabaseConnection
|
|||
public function set($connection, $host, $database = 'mysql')
|
||||
{
|
||||
if (! $host instanceof DatabaseHost) {
|
||||
$host = $this->model->findOrFail($host);
|
||||
$host = $this->repository->find($host);
|
||||
}
|
||||
|
||||
$this->config->set('database.connections.' . $connection, [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue