45 lines
910 B
PHP
45 lines
910 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[Fillable([
|
|
'source',
|
|
'external_id',
|
|
'name',
|
|
'slug',
|
|
'description',
|
|
'is_favorite',
|
|
'synced_at',
|
|
])]
|
|
class ContactGroup extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
/**
|
|
* @return BelongsToMany<Contact, $this>
|
|
*/
|
|
public function contacts(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Contact::class, 'contact_contact_group')
|
|
->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_favorite' => 'boolean',
|
|
'synced_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|