Path: blob/1.0-develop/app/Http/Middleware/Api/Client/SubstituteClientBindings.php
10277 views
<?php12namespace Pterodactyl\Http\Middleware\Api\Client;34use Pterodactyl\Models\Server;5use Illuminate\Routing\Middleware\SubstituteBindings;67class SubstituteClientBindings extends SubstituteBindings8{9/**10* @param \Illuminate\Http\Request $request11*/12public function handle($request, \Closure $next): mixed13{14// Override default behavior of the model binding to use a specific table15// column rather than the default 'id'.16$this->router->bind('server', function ($value) {17return Server::query()->where(strlen($value) === 8 ? 'uuidShort' : 'uuid', $value)->firstOrFail();18});1920$this->router->bind('user', function ($value, $route) {21/** @var \Pterodactyl\Models\Subuser $match */22$match = $route->parameter('server')23->subusers()24->whereRelation('user', 'uuid', '=', $value)25->firstOrFail();2627return $match->user;28});2930return parent::handle($request, $next);31}32}333435