<?php

namespace App\Models;

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

class UserCourseStat extends Model
{
    protected $fillable = [
        'user_id',
        'course_id',
        'total_answered',
        'correct_answered',
        'last_studied_at',
        'streak',
        'last_streak_date',
    ];

    protected function casts(): array
    {
        return [
            'last_studied_at' => 'datetime',
            'last_streak_date' => 'date',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function course(): BelongsTo
    {
        return $this->belongsTo(Course::class);
    }
}
