<?php

namespace App\Models;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;

class ReviewFeedback extends Model
{
    use BelongsToTenant;

    protected $table = 'review_feedback';

    protected $fillable = [
        'tenant_id', 'patient_id', 'appointment_id', 'rating', 'comment', 'submitted_at',
    ];

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

    protected static function booted(): void
    {
        static::creating(fn (ReviewFeedback $r) => $r->uuid ??= (string) Str::uuid());
    }

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