2017-07-03 02:29:58 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-07-03 02:29:58 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-07-03 02:29:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Eloquent;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Location;
|
2017-08-27 19:55:25 +00:00
|
|
|
use Pterodactyl\Repositories\Concerns\Searchable;
|
2017-07-03 02:29:58 +00:00
|
|
|
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
|
|
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|
|
|
|
2017-08-19 03:19:06 +00:00
|
|
|
class LocationRepository extends EloquentRepository implements LocationRepositoryInterface
|
2017-07-03 02:29:58 +00:00
|
|
|
{
|
2017-08-19 03:19:06 +00:00
|
|
|
use Searchable;
|
|
|
|
|
2017-07-03 02:29:58 +00:00
|
|
|
/**
|
2017-07-08 19:07:51 +00:00
|
|
|
* {@inheritdoc}
|
2017-07-03 02:29:58 +00:00
|
|
|
*/
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Location::class;
|
|
|
|
}
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2017-08-09 04:24:55 +00:00
|
|
|
public function getAllWithDetails()
|
2017-07-23 19:51:18 +00:00
|
|
|
{
|
|
|
|
return $this->getBuilder()->withCount('nodes', 'servers')->get($this->getColumns());
|
|
|
|
}
|
|
|
|
|
2017-08-09 04:24:55 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getAllWithNodes()
|
|
|
|
{
|
|
|
|
return $this->getBuilder()->with('nodes')->get($this->getColumns());
|
|
|
|
}
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getWithNodes($id)
|
|
|
|
{
|
|
|
|
$instance = $this->getBuilder()->with('nodes.servers')->find($id, $this->getColumns());
|
2017-09-15 05:16:03 +00:00
|
|
|
if (! $instance) {
|
|
|
|
throw new RecordNotFoundException;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
2017-07-23 19:51:18 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getWithNodeCount($id)
|
|
|
|
{
|
|
|
|
$instance = $this->getBuilder()->withCount('nodes')->find($id, $this->getColumns());
|
2017-07-23 19:51:18 +00:00
|
|
|
if (! $instance) {
|
2017-09-15 05:16:03 +00:00
|
|
|
throw new RecordNotFoundException;
|
2017-07-23 19:51:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
2017-07-03 02:29:58 +00:00
|
|
|
}
|