2019-11-24 20:50:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\View\View;
|
2019-11-24 20:50:16 +00:00
|
|
|
use Illuminate\Http\Request;
|
2020-09-13 19:21:44 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use Spatie\QueryBuilder\QueryBuilder;
|
2020-10-26 00:29:57 +00:00
|
|
|
use Spatie\QueryBuilder\AllowedFilter;
|
2019-11-24 20:50:16 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
2020-10-26 00:29:57 +00:00
|
|
|
use Pterodactyl\Models\Filters\AdminServerFilter;
|
2019-11-24 20:50:16 +00:00
|
|
|
|
|
|
|
class ServerController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
2022-10-14 16:59:20 +00:00
|
|
|
* Returns all the servers that exist on the system using a paginated result set. If
|
2019-11-24 20:50:16 +00:00
|
|
|
* a query is passed along in the request it is also passed to the repository function.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function index(Request $request): View
|
2019-11-24 20:50:16 +00:00
|
|
|
{
|
2020-09-13 19:21:44 +00:00
|
|
|
$servers = QueryBuilder::for(Server::query()->with('node', 'user', 'allocation'))
|
2020-10-26 00:29:57 +00:00
|
|
|
->allowedFilters([
|
|
|
|
AllowedFilter::exact('owner_id'),
|
2021-01-23 20:33:34 +00:00
|
|
|
AllowedFilter::custom('*', new AdminServerFilter()),
|
2020-10-26 00:29:57 +00:00
|
|
|
])
|
2020-09-13 19:21:44 +00:00
|
|
|
->paginate(config()->get('pterodactyl.paginate.admin.servers'));
|
|
|
|
|
2022-11-28 16:56:03 +00:00
|
|
|
return view('admin.servers.index', ['servers' => $servers]);
|
2019-11-24 20:50:16 +00:00
|
|
|
}
|
|
|
|
}
|