<?php

namespace App\Models;

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

class Company extends Model
{
    use HasFactory;

    protected $table = 'companies';

    /**
     * Possible module types.
     */
    public const TYPE_COMPANY = 'company';

    public const TYPE_ORGANIZATION = 'organization';

    public const TYPE_ASSOCIATION = 'association';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'vault_id',
        'name',
        'type',
    ];

    /**
     * Get the vault associated with the company.
     */
    public function vault(): BelongsTo
    {
        return $this->belongsTo(Vault::class);
    }

    /**
     * Get the contacts associated with the company.
     */
    public function contacts(): HasMany
    {
        return $this->hasMany(Contact::class);
    }
}
