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\Repository\Eloquent;
use HiEvents\DomainObjects\WebhookLogDomainObject;
use HiEvents\Models\WebhookLog;
use HiEvents\Repository\Interfaces\WebhookLogRepositoryInterface;
/**
* @extends BaseRepository<WebhookLogDomainObject>
*/
class WebhookLogRepository extends BaseRepository implements WebhookLogRepositoryInterface
{
protected function getModel(): string
{
return WebhookLog::class;
}
public function getDomainObject(): string
{
return WebhookLogDomainObject::class;
}
/**
* @todo This should be a scheduled task
*/
public function deleteOldLogs(int $webhookId, int $numberToKeep = 20): void
{
$query = $this->model->where('webhook_id', $webhookId);
$totalLogs = $query->count();
if ($totalLogs > $numberToKeep) {
$query->orderBy('created_at', 'desc')
->skip($numberToKeep)
->take($totalLogs - $numberToKeep)
->forceDelete();
}
}
}