api(application): v2 backport
This commit is contained in:
parent
4cd0bee231
commit
67bf3e342e
172 changed files with 2922 additions and 1579 deletions
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace Pterodactyl\Transformers\Api\Client;
|
||||
|
||||
use Pterodactyl\Models\Task;
|
||||
use Pterodactyl\Models\Schedule;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use Pterodactyl\Transformers\Api\Transformer;
|
||||
|
||||
class ScheduleTransformer extends BaseClientTransformer
|
||||
class ScheduleTransformer extends Transformer
|
||||
{
|
||||
protected array $availableIncludes = ['tasks'];
|
||||
|
||||
|
@ -38,24 +38,18 @@ class ScheduleTransformer extends BaseClientTransformer
|
|||
'is_active' => $model->is_active,
|
||||
'is_processing' => $model->is_processing,
|
||||
'only_when_online' => $model->only_when_online,
|
||||
'last_run_at' => $model->last_run_at?->toAtomString(),
|
||||
'next_run_at' => $model->next_run_at?->toAtomString(),
|
||||
'created_at' => $model->created_at->toAtomString(),
|
||||
'updated_at' => $model->updated_at->toAtomString(),
|
||||
'last_run_at' => self::formatTimestamp($model->last_run_at),
|
||||
'next_run_at' => self::formatTimestamp($model->next_run_at),
|
||||
'created_at' => self::formatTimestamp($model->created_at),
|
||||
'updated_at' => self::formatTimestamp($model->updated_at),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows attaching the tasks specific to the schedule in the response.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeTasks(Schedule $model): Collection
|
||||
{
|
||||
return $this->collection(
|
||||
$model->tasks,
|
||||
$this->makeTransformer(TaskTransformer::class),
|
||||
Task::RESOURCE_NAME
|
||||
);
|
||||
return $this->collection($model->tasks, new TaskTransformer());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue