<?php

namespace App\Domain\Website\Models;

use App\Domain\Shared\Traits\BelongsToAcademy;
use App\Domain\Shared\Traits\HasUuid;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class WebsiteTestimonial extends Model
{
    use BelongsToAcademy, HasUuid, SoftDeletes;

    protected $fillable = [
        'academy_id',
        'name',
        'name_en',
        'role',
        'role_en',
        'content',
        'content_en',
        'rating',
        'is_featured',
        'sort_order',
    ];

    protected $casts = [
        'rating' => 'integer',
        'is_featured' => 'boolean',
        'sort_order' => 'integer',
    ];

    public function avatar(): MorphOne
    {
        return $this->morphOne(Media::class, 'mediable')
            ->where('collection', 'testimonial_avatar');
    }
}
