Update repository base code to be cleaner and make use of PHP 7 features
This commit is contained in:
parent
0ec5a4e08c
commit
60eb60013c
96 changed files with 1048 additions and 1785 deletions
|
@ -1,15 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
|
||||
|
@ -17,7 +9,9 @@ use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
|
|||
class SubuserRepository extends EloquentRepository implements SubuserRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Return the model backing this repository.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
|
@ -86,39 +80,4 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI
|
|||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getWithServerAndPermissions($id)
|
||||
{
|
||||
Assert::numeric($id, 'First argument passed to getWithServerAndPermissions must be numeric, received %s.');
|
||||
|
||||
$instance = $this->getBuilder()->with('server', 'permission', 'user')->find($id, $this->getColumns());
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getWithKey($user, $server)
|
||||
{
|
||||
Assert::integerish($user, 'First argument passed to getWithKey must be integer, received %s.');
|
||||
Assert::integerish($server, 'Second argument passed to getWithKey must be integer, received %s.');
|
||||
|
||||
$instance = $this->getBuilder()->with('key')->where([
|
||||
['user_id', '=', $user],
|
||||
['server_id', '=', $server],
|
||||
])->first();
|
||||
|
||||
if (is_null($instance)) {
|
||||
throw new RecordNotFoundException;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue