Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Services\Domain\Event;
use HiEvents\DomainObjects\Enums\ImageType;
use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\DomainObjects\ImageDomainObject;
use HiEvents\Repository\Interfaces\ImageRepositoryInterface;
use HiEvents\Services\Domain\Image\ImageUploadService;
use Illuminate\Database\DatabaseManager;
use Illuminate\Http\UploadedFile;
use Throwable;
/**
* @deprecated use CreateImageAction
*/
class CreateEventImageService
{
public function __construct(
private readonly ImageUploadService $imageUploadService,
private readonly ImageRepositoryInterface $imageRepository,
private readonly DatabaseManager $databaseManager,
) {}
/**
* @throws Throwable
*/
public function createImage(
int $eventId,
int $accountId,
UploadedFile $image,
ImageType $imageType,
): ImageDomainObject {
return $this->databaseManager->transaction(function () use ($accountId, $image, $eventId, $imageType) {
if ($imageType === ImageType::EVENT_COVER) {
$this->imageRepository->deleteWhere([
'entity_id' => $eventId,
'entity_type' => EventDomainObject::class,
'type' => ImageType::EVENT_COVER->name,
]);
}
return $this->imageUploadService->upload(
image: $image,
entityId: $eventId,
entityType: EventDomainObject::class,
imageType: $imageType->name,
accountId: $accountId,
);
});
}
}