id === null) { throw new BadRequestException('id is required'); } if ($request->title === null || trim($request->title) === '') { throw new BadRequestException('title is required'); } $element = $this->elementRepository->find($request->id); if ($element === null) { throw new NotFoundException('Element not found'); } return $this->elementRepository->update( $element, new UpdateElementDto( title: $request->title, description: $request->description ?? '', iconImageUrl: $this->nullableString($request->iconImageUrl), richText: $request->richText ?? '', pdfPath: $this->nullableString($request->pdfPath), youtubeUrl: $this->nullableString($request->youtubeUrl), ), ); } private function nullableString(?string $value): ?string { if ($value === null || $value === '') { return null; } return $value; } }