<?php

namespace Modules\MedPortal\Entities;

use Illuminate\Database\Eloquent\Model;

/**
 * A guardian↔dependent-patient link (SIFA Phase 8, family management). The
 * guardian is an ERP contacts.id (also the PortalApi portal_owner); the
 * dependent is a clc_patients.id.
 */
class MportalDependent extends Model
{
    protected $table = 'mportal_dependents';

    protected $guarded = ['id'];

    protected $casts = [
        'can_book'         => 'boolean',
        'can_view_records' => 'boolean',
    ];

    public const RELATIONSHIPS = ['child', 'spouse', 'parent', 'sibling', 'other'];

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