<?php

namespace App\Models;

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

class Review extends Model
{
    protected $fillable = [
        'trip_id', 'reviewer_id', 'reviewee_id', 'role',
        'rating_punctuality', 'rating_safety', 'rating_comfort',
        'rating_communication', 'overall_rating', 'comment',
    ];

    protected function casts(): array
    {
        return ['overall_rating' => 'decimal:2'];
    }

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

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

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