<?php

namespace Modules\VetPortal\Entities;

use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Contact;

/**
 * A pet-owner login account for the public portal. Authenticated through the
 * dedicated `pet_owner` guard — fully separate from ERP staff (`web` guard).
 */
class VpPortalAccount extends Authenticatable
{
    protected $table = 'vp_portal_accounts';
    protected $guarded = ['id'];

    protected $hidden = ['password', 'remember_token'];

    protected $casts = [
        'enabled'       => 'boolean',
        'last_login_at' => 'datetime',
    ];

    public function contact()
    {
        return $this->belongsTo(Contact::class, 'contact_id');
    }

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