<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class RouletteItem extends Model
{
    protected $fillable = [
        'roulette_category_id',
        'name',
        'image_path',
        'weight',
        'value_min',
        'value_max',
    ];

    protected function casts(): array
    {
        return [
            'weight' => 'integer',
            'value_min' => 'integer',
            'value_max' => 'integer',
        ];
    }

    public function category()
    {
        return $this->belongsTo(RouletteCategory::class, 'roulette_category_id');
    }

    public function rollValue(): int
    {
        return random_int($this->value_min, $this->value_max);
    }
}
