Path: blob/1.0-develop/app/Transformers/Api/Client/ScheduleTransformer.php
10284 views
<?php12namespace Pterodactyl\Transformers\Api\Client;34use Pterodactyl\Models\Task;5use Pterodactyl\Models\Schedule;6use League\Fractal\Resource\Collection;78class ScheduleTransformer extends BaseClientTransformer9{10protected array $availableIncludes = ['tasks'];1112protected array $defaultIncludes = ['tasks'];1314public function getResourceName(): string15{16return Schedule::RESOURCE_NAME;17}1819/**20* Returns a transformed schedule model such that a client can view the information.21*/22public function transform(Schedule $model): array23{24return [25'id' => $model->id,26'name' => $model->name,27'cron' => [28'day_of_week' => $model->cron_day_of_week,29'day_of_month' => $model->cron_day_of_month,30'month' => $model->cron_month,31'hour' => $model->cron_hour,32'minute' => $model->cron_minute,33],34'is_active' => $model->is_active,35'is_processing' => $model->is_processing,36'only_when_online' => $model->only_when_online,37'last_run_at' => $model->last_run_at?->toAtomString(),38'next_run_at' => $model->next_run_at?->toAtomString(),39'created_at' => $model->created_at->toAtomString(),40'updated_at' => $model->updated_at->toAtomString(),41];42}4344/**45* Allows attaching the tasks specific to the schedule in the response.46*47* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException48*/49public function includeTasks(Schedule $model): Collection50{51return $this->collection(52$model->tasks,53$this->makeTransformer(TaskTransformer::class),54Task::RESOURCE_NAME55);56}57}585960