misc_pterodactyl-panel/app/Repositories/Eloquent/LocationRepository.php

76 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2017-09-26 02:43:01 +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
*/
namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Location;
2017-08-27 19:55:25 +00:00
use Pterodactyl\Repositories\Concerns\Searchable;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
class LocationRepository extends EloquentRepository implements LocationRepositoryInterface
{
use Searchable;
/**
* @var string
*/
protected $searchTerm;
/**
* {@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;
}
}