<?php

namespace App\Models;

use App\Models\Concerns\BelongsToCompany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class TreatmentRecord extends Model
{
    use HasFactory, SoftDeletes, BelongsToCompany;

    protected $fillable = [
        'company_id', 'clinical_history_id',
        'booking_id', 'service_id', 'employee_id',
        'performed_at', 'description',
        'products_used', 'observations', 'recommendations',
        'next_appointment_suggested',
        'photo_before_path', 'photo_after_path',
        'additional_photos', 'client_signature_path',
    ];

    protected function casts(): array
    {
        return [
            'performed_at'                => 'date',
            'next_appointment_suggested'  => 'date',
            'products_used'               => 'array',
            'additional_photos'           => 'array',
            'observations'                => 'encrypted',
            'recommendations'             => 'encrypted',
        ];
    }

    public function history(): BelongsTo
    {
        return $this->belongsTo(ClinicalHistory::class, 'clinical_history_id');
    }

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

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

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