Files
monica/app/Models/LifeMetric.php

46 lines
1.1 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\BelongsToMany;
class LifeMetric extends Model
{
use HasFactory;
protected $table = 'life_metrics';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'vault_id',
'label',
];
/**
* Get the vault associated with the life metric.
*
* @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 life metric.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\Contact, $this>
*/
public function contacts(): BelongsToMany
{
return $this->belongsToMany(Contact::class, 'contact_life_metric', 'contact_id', 'life_metric_id')->withTimestamps();
}
}