<?php

namespace App\Services;

use App\Core\Database;

class HomepageLifecycleService
{

public static function archive(
int $conferenceId,
int $userId
): bool
{

$db=
Database::getInstance();

return
$db
->prepare("

INSERT INTO
conference_home_lifecycle(

conference_id,

lifecycle_state,

metadata_json,

created_by

)

VALUES(

?,

'archived',

JSON_OBJECT(

'time',

NOW()

),

?

)

")

->execute([

$conferenceId,

$userId

]);

}

public static function status(
int $conferenceId
)
{

$db=
Database::getInstance();

$stmt=
$db
->prepare("

SELECT

lifecycle_state,

created_at

FROM
conference_home_lifecycle

WHERE conference_id=?

ORDER BY id DESC

LIMIT 1

");

$stmt
->execute([

$conferenceId

]);

return
$stmt
->fetch()

??

[

'lifecycle_state'=>

'active'

];

}

}
