repository = $repository; } /** * Returns an array of all roles. * * @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request * * @return array */ public function index(GetRolesRequest $request) { return $this->fractal->collection(AdminRole::all()) ->transformWith($this->getTransformer(AdminRoleTransformer::class)) ->toArray(); } /** * Returns a single role. * * @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request * @param \Pterodactyl\Models\AdminRole $role * * @return array */ public function view(GetRolesRequest $request, AdminRole $role): array { return $this->fractal->item($role) ->transformWith($this->getTransformer(AdminRoleTransformer::class)) ->toArray(); } /** * Creates a new role. * * @param \Pterodactyl\Http\Requests\Api\Application\Roles\StoreRoleRequest $request * * @return \Illuminate\Http\JsonResponse */ public function store(StoreRoleRequest $request) { $role = AdminRole::query()->create($request->validated()); return $this->fractal->item($role) ->transformWith($this->getTransformer(AdminRoleTransformer::class)) ->respond(JsonResponse::HTTP_CREATED); } /** * Updates a role. * * @param \Pterodactyl\Http\Requests\Api\Application\Roles\UpdateRoleRequest $request * @param \Pterodactyl\Models\AdminRole $role * * @return array */ public function update(UpdateRoleRequest $request, AdminRole $role) { $role->update($request->validated()); return $this->fractal->item($role) ->transformWith($this->getTransformer(AdminRoleTransformer::class)) ->toArray(); } /** * Deletes a role. * * @param \Pterodactyl\Http\Requests\Api\Application\Roles\DeleteRoleRequest $request * @param \Pterodactyl\Models\AdminRole $role * * @return \Illuminate\Http\JsonResponse */ public function delete(DeleteRoleRequest $request, AdminRole $role) { $this->repository->delete($role->id); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } }