<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;

class Vocabulary extends Model
{
    use HasFactory, HasUuids;

    protected $fillable = [
        'word', 'reading', 'romaji', 'meaning_en', 'meaning_id',
        'level_id', 'audio_url', 'type', 'stroke_order_svg', 'example_sentences'
    ];

    protected $casts = [
        'stroke_order_svg' => 'array',
        'example_sentences' => 'array',
    ];

    public function reviews()
    {
        return $this->hasMany(SrsReview::class);
    }

    public function level()
    {
        return $this->belongsTo(Level::class);
    }

    public function lessons()
    {
        return $this->belongsToMany(Lesson::class, 'lesson_vocabulary');
    }
}
