97 lines
2.0 KiB
PHP
97 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Contact;
|
|
|
|
use App\Traits\HasUuid;
|
|
use App\Models\Account\Account;
|
|
use App\Models\ModelBinding as Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class LifeEvent extends Model
|
|
{
|
|
use HasUuid;
|
|
|
|
protected $table = 'life_events';
|
|
|
|
/**
|
|
* The attributes that aren't mass assignable.
|
|
*
|
|
* @var array<string>|bool
|
|
*/
|
|
protected $guarded = ['id'];
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'note',
|
|
'happened_at',
|
|
'account_id',
|
|
'contact_id',
|
|
'reminder_id',
|
|
'life_event_type_id',
|
|
'happened_at_month_unknown',
|
|
'happened_at_day_unknown',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array<string>
|
|
*/
|
|
protected $dates = ['happened_at'];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'happened_at_month_unknown' => 'boolean',
|
|
'happened_at_day_unknown' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Get the account record associated with the life event.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function account()
|
|
{
|
|
return $this->belongsTo(Account::class);
|
|
}
|
|
|
|
/**
|
|
* Get the contact record associated with the life event.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function contact()
|
|
{
|
|
return $this->belongsTo(Contact::class);
|
|
}
|
|
|
|
/**
|
|
* Get the life event type record associated with the life event.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function lifeEventType()
|
|
{
|
|
return $this->belongsTo(LifeEventType::class, 'life_event_type_id');
|
|
}
|
|
|
|
/**
|
|
* Get the reminder record associated with the life event.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function reminder()
|
|
{
|
|
return $this->belongsTo(Reminder::class);
|
|
}
|
|
}
|