<?php

namespace App\Services;

use App\Core\Database;

class AuthorRegistrationService
{

    public static function assignAuthorRole($userId)
    {
        $db = Database::getInstance();

        $stmt = $db->prepare("
            INSERT INTO conference_roles
            (conference_id, user_id, role_code)
            SELECT 1, ?, 'author'
            WHERE NOT EXISTS (
                SELECT 1
                FROM conference_roles
                WHERE user_id = ?
                AND conference_id = 1
            )
        ");

        $stmt->execute([
            $userId,
            $userId
        ]);
    }

}
