<?php

namespace App\Models;

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

class Rating extends Model
{
    protected $fillable = ['booking_id', 'rater_type', 'rater_id', 'ratee_type', 'ratee_id', 'stars', 'comment'];

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

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

    public function rater(): MorphTo
    {
        return $this->morphTo();
    }

    public function ratee(): MorphTo
    {
        return $this->morphTo();
    }
}
