<?php

namespace App\Models;

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

class ArtigoVoto extends Model
{
    use HasFactory;

    protected $table = 'artigo_votos';

    protected $fillable = [
        'artigo_id',
        'user_id',
        'valor',
        'feedback',
    ];

    protected $casts = [
        'valor' => 'integer',
    ];

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

    public function usuario(): BelongsTo
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
