Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -20,35 +20,25 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest;
class ScheduleTaskController extends ClientApiController
{
/**
* @var \Pterodactyl\Repositories\Eloquent\TaskRepository
*/
private $repository;
/**
* ScheduleTaskController constructor.
*/
public function __construct(TaskRepository $repository)
public function __construct(private TaskRepository $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Create a new task for a given schedule and store it in the database.
*
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\HttpForbiddenException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\ServiceLimitExceededException
*/
public function store(StoreTaskRequest $request, Server $server, Schedule $schedule)
public function store(StoreTaskRequest $request, Server $server, Schedule $schedule): array
{
$limit = config('pterodactyl.client_features.schedules.per_schedule_task_limit', 10);
if ($schedule->tasks()->count() >= $limit) {
throw new ServiceLimitExceededException("Schedules may not have more than {$limit} tasks associated with them. Creating this task would put this schedule over the limit.");
throw new ServiceLimitExceededException("Schedules may not have more than $limit tasks associated with them. Creating this task would put this schedule over the limit.");
}
if ($server->backup_limit === 0 && $request->action === 'backup') {
@ -81,13 +71,10 @@ class ScheduleTaskController extends ClientApiController
/**
* Updates a given task for a server.
*
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\HttpForbiddenException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task)
public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task): array
{
if ($schedule->id !== $task->schedule_id || $server->id !== $schedule->server_id) {
throw new NotFoundHttpException();
@ -118,11 +105,9 @@ class ScheduleTaskController extends ClientApiController
* Delete a given task for a schedule. If there are subsequent tasks stored in the database
* for this schedule their sequence IDs are decremented properly.
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
*/
public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task)
public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task): JsonResponse
{
if ($task->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
throw new NotFoundHttpException();