fractal->collection(UserSSHKey::query()->where('user_id', '=', $request->user()->id)->get()) ->transformWith(UserSSHKeyTransformer::class); } /** * ? * * @throws \Illuminate\Contracts\Container\BindingResolutionException * @throws \Pterodactyl\Exceptions\DisplayException */ public function store(StoreSSHKeyRequest $request): JsonResponse { if ($request->user()->sshKeys->count() >= 5) { throw new DisplayException('You have reached the account limit for number of SSH keys.'); } $data = array_merge($request->validated(), [ 'user_id' => $request->user()->id, ]); $key = UserSSHKey::query()->create($data); return $this->fractal->item($key) ->transformWith(UserSSHKeyTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } /** * ? */ public function delete(Request $request, UserSSHKey $sshKey): Response { $sshKey->delete(); return new Response('', Response::HTTP_NO_CONTENT); } }