<?php

namespace App\Services;

use App\Core\Database;

class HomepageSchedulerService
{

public static function schedule(
int $conferenceId,
string $job,
string $when,
int $userId
)
{

$db=
Database::getInstance();

return
$db
->prepare("

INSERT INTO
conference_home_schedule(

conference_id,

job_name,

execute_at,

created_by

)

VALUES(

?,

?,

?,

?

)

")

->execute([

$conferenceId,

$job,

$when,

$userId

]);

}

public static function next(
int $conferenceId
)
{

$db=
Database::getInstance();

$stmt=
$db
->prepare("

SELECT *

FROM
conference_home_schedule

WHERE conference_id=?

AND job_status='scheduled'

ORDER BY execute_at

LIMIT 1

");

$stmt
->execute([

$conferenceId

]);

return
$stmt
->fetch()

??

[];

}

}
