<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Rating extends Model
{
    protected $fillable = [
        'user_id', 'order_id', 'rateable_type', 'rateable_id',
        'stars', 'comment', 'is_verified_purchase', 'is_hidden',
    ];

    protected function casts(): array
    {
        return [
            'stars'                => 'integer',
            'is_verified_purchase' => 'boolean',
            'is_hidden'            => 'boolean',
        ];
    }

    public function user()     { return $this->belongsTo(User::class); }
    public function order()    { return $this->belongsTo(Order::class); }
    public function rateable() { return $this->morphTo(); }
}
