56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?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 list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'vault_id',
|
|
'name',
|
|
'type',
|
|
];
|
|
|
|
/**
|
|
* Get the vault associated with the company.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Vault, $this>
|
|
*/
|
|
public function vault(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Vault::class);
|
|
}
|
|
|
|
/**
|
|
* Get the contacts associated with the company.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Contact, $this>
|
|
*/
|
|
public function contacts(): HasMany
|
|
{
|
|
return $this->hasMany(Contact::class);
|
|
}
|
|
}
|