Files
monica/app/Models/Tag.php
T

52 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;
use Illuminate\Database\Eloquent\Relations\MorphOne;
class Tag extends Model
{
use HasFactory;
protected $table = 'tags';
/**
* The attributes that are mass assignable.
*
* @var array<string>
*/
protected $fillable = [
'vault_id',
'name',
'slug',
];
/**
* Get the vault associated with the journal tag.
*/
public function vault(): BelongsTo
{
return $this->belongsTo(Vault::class);
}
/**
* Get the posts associated with the journal tag.
*/
public function posts(): BelongsToMany
{
return $this->belongsToMany(Post::class);
}
/**
* Get the journal tag's feed item.
*/
public function feedItem(): MorphOne
{
return $this->morphOne(ContactFeedItem::class, 'feedable');
}
}