68 lines
1.3 KiB
PHP
68 lines
1.3 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;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
class Group extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'groups';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'vault_id',
|
|
'group_type_id',
|
|
'name',
|
|
];
|
|
|
|
/**
|
|
* Get the vault associated with the group.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function vault(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Vault::class);
|
|
}
|
|
|
|
/**
|
|
* Get the vault associated with the group.
|
|
*
|
|
* @return BelongsTo
|
|
*/
|
|
public function groupType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(GroupType::class);
|
|
}
|
|
|
|
/**
|
|
* Get the contacts associated with the group.
|
|
*
|
|
* @return BelongsToMany
|
|
*/
|
|
public function contacts(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Contact::class);
|
|
}
|
|
|
|
/**
|
|
* Get the group's feed item.
|
|
*
|
|
* @return MorphOne
|
|
*/
|
|
public function feedItem(): MorphOne
|
|
{
|
|
return $this->morphOne(ContactFeedItem::class, 'feedable');
|
|
}
|
|
}
|