<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Company extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'name',
        'email',
        'phone',
        'rc_number',
        'address',
        'city',
        'state',
        'country',
        'insurance_type',
        'registration_date',
        'license_number',
        'status',
        'registration_token',
    ];

    /**
     * Get the portal users for the company.
     */
    public function portalUsers(): HasMany
    {
        return $this->hasMany(PortalUser::class);
    }

    /**
     * Get the employees for the company.
     */
    public function employees(): HasMany
    {
        return $this->hasMany(CompanyEmployee::class);
    }

    /**
     * Get the Company registrations for the company.
     */
    public function kycSubmissions(): HasMany
    {
        return $this->hasMany(CompanyRegistration::class);
    }

    /**
     * Check if company is active.
     */
    public function isActive(): bool
    {
        return $this->status === 'active';
    }
}
