76 lines
1.8 KiB
PHP
76 lines
1.8 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\MorphOne;
|
|
|
|
class ContactImportantDate extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'contact_important_dates';
|
|
|
|
/**
|
|
* Possible types.
|
|
*/
|
|
public const TYPE_BIRTHDATE = 'birthdate';
|
|
|
|
public const TYPE_DECEASED_DATE = 'deceased_date';
|
|
|
|
/**
|
|
* Possible type of dates.
|
|
*/
|
|
public const TYPE_FULL_DATE = 'full_date';
|
|
|
|
public const TYPE_MONTH_DAY = 'month_day';
|
|
|
|
public const TYPE_YEAR = 'year';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'contact_id',
|
|
'label',
|
|
'day',
|
|
'month',
|
|
'year',
|
|
'contact_important_date_type_id',
|
|
];
|
|
|
|
/**
|
|
* Get the contact associated with the contact date.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Contact, $this>
|
|
*/
|
|
public function contact(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Contact::class);
|
|
}
|
|
|
|
/**
|
|
* Get the important date type associated with the contact date.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\ContactImportantDateType, $this>
|
|
*/
|
|
public function contactImportantDateType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ContactImportantDateType::class);
|
|
}
|
|
|
|
/**
|
|
* Get the important date's feed item.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphOne<\App\Models\ContactFeedItem, $this>
|
|
*/
|
|
public function feedItem(): MorphOne
|
|
{
|
|
return $this->morphOne(ContactFeedItem::class, 'feedable');
|
|
}
|
|
}
|