<?php

namespace Modules\ClinicCore\Entities;

use Illuminate\Database\Eloquent\Model;
use App\User;

/**
 * SIFA P3-T3 — an amendment to a signed / locked SOAP note section.
 */
class ClcNoteAmendment extends Model
{
    protected $table = 'clc_note_amendments';
    protected $guarded = ['id'];
    public $timestamps = false;   // only created_at (set explicitly on write)

    protected $casts = [
        'created_at' => 'datetime',
    ];

    public const SECTIONS = ['subjective', 'objective', 'assessment', 'plan', 'investigations', 'other'];

    public function appointment()
    {
        return $this->belongsTo(ClcAppointment::class, 'appointment_id');
    }

    public function amender()
    {
        return $this->belongsTo(User::class, 'amended_by');
    }

    public function scopeForBusiness($query, $businessId)
    {
        return $query->where('business_id', $businessId);
    }
}
