misc_pterodactyl-panel/app/Repositories/Eloquent/LocationRepository.php
Anand Capur e085b8e109 enable php 7.2 in travis and fix repository (#797)
This was really amusing to watch @arcdigital attempt to do.
2017-12-05 09:26:29 -06:00

70 lines
1.6 KiB
PHP

<?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 Pterodactyl\Models\Location;
use Pterodactyl\Repositories\Concerns\Searchable;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
class LocationRepository extends EloquentRepository implements LocationRepositoryInterface
{
use Searchable;
/**
* {@inheritdoc}
*/
public function model()
{
return Location::class;
}
/**
* {@inheritdoc}
*/
public function getAllWithDetails()
{
return $this->getBuilder()->withCount('nodes', 'servers')->get($this->getColumns());
}
/**
* {@inheritdoc}
*/
public function getAllWithNodes()
{
return $this->getBuilder()->with('nodes')->get($this->getColumns());
}
/**
* {@inheritdoc}
*/
public function getWithNodes($id)
{
$instance = $this->getBuilder()->with('nodes.servers')->find($id, $this->getColumns());
if (! $instance) {
throw new RecordNotFoundException;
}
return $instance;
}
/**
* {@inheritdoc}
*/
public function getWithNodeCount($id)
{
$instance = $this->getBuilder()->withCount('nodes')->find($id, $this->getColumns());
if (! $instance) {
throw new RecordNotFoundException;
}
return $instance;
}
}