Path: blob/1.0-develop/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php
10279 views
<?php12namespace Pterodactyl\Http\Requests\Api\Client\Servers\Schedules;34use Pterodactyl\Models\Task;5use Pterodactyl\Models\Server;6use Pterodactyl\Models\Schedule;7use Pterodactyl\Models\Permission;8use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;9use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;1011class ViewScheduleRequest extends ClientApiRequest12{13/**14* Determine if this resource can be viewed.15*/16public function authorize(): bool17{18if (!parent::authorize()) {19return false;20}2122$server = $this->route()->parameter('server');23$schedule = $this->route()->parameter('schedule');2425// If the schedule does not belong to this server throw a 404 error. Also throw an26// error if the task being requested does not belong to the associated schedule.27if ($server instanceof Server && $schedule instanceof Schedule) {28$task = $this->route()->parameter('task');2930if ($schedule->server_id !== $server->id || ($task instanceof Task && $task->schedule_id !== $schedule->id)) {31throw new NotFoundHttpException('The requested resource does not exist on the system.');32}33}3435return true;36}3738public function permission(): string39{40return Permission::ACTION_SCHEDULE_READ;41}42}434445