<?php

namespace App\Services;

use App\Core\Database;

class HomepageReviewService
{

public static function queue(
int $conferenceId,
string $type,
array $payload,
int $userId
): bool
{

$db=
Database::getInstance();

return
$db
->prepare("

INSERT INTO
conference_home_timeline(

conference_id,

entity_type,

change_type,

change_json,

created_by

)

VALUES(

?,

'homepage',

?,

?,

?

)

")

->execute([

$conferenceId,

$type,

json_encode(
$payload,
JSON_UNESCAPED_UNICODE
),

$userId

]);

}

public static function latest(
int $conferenceId
): array
{

$db=
Database::getInstance();

$stmt=
$db
->prepare("

SELECT

id,

change_type,

approval_state,

created_at

FROM
conference_home_timeline

WHERE conference_id=?

ORDER BY id DESC

LIMIT 20

");

$stmt
->execute([

$conferenceId

]);

return
$stmt
->fetchAll()

??

[];

}

}
