<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @property int $id
 * @property int $course_id
 * @property bool $certificate_enabled
 * @property string|null $certificate_template
 * @property bool $badge_enabled
 * @property int|null $retakes
 * @property string|null $instructions
 * @property array|null $instructions_json
 * @property string|null $completion_message
 * @property array|null $completion_message_json
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 */
class LmsCourseSettings extends Model
{
    protected $table = 'lms_course_settings';

    protected $fillable = [
        'course_id',
        'certificate_enabled',
        'certificate_template',
        'badge_enabled',
        'retakes',
        'instructions',
        'instructions_json',
        'completion_message',
        'completion_message_json',
    ];

    protected $casts = [
        'certificate_enabled' => 'boolean',
        'badge_enabled' => 'boolean',
        'instructions_json' => 'array',
        'completion_message_json' => 'array',
    ];

    // Relationships
    public function course(): BelongsTo
    {
        return $this->belongsTo(LmsCourse::class, 'course_id');
    }
}
