*/ use HasFactory; use SoftDeletes; protected $fillable = [ 'title', 'slug', 'content', 'excerpt', 'status', 'published_at', 'author_id', 'category_id' ]; protected $casts = [ 'published_at' => 'datetime', ]; protected function avgReadingTime(): Attribute { return new Attribute( get: fn ($value) => ceil(str_word_count($this->content) / 100) ); } public function author(): BelongsTo { return $this->belongsTo(User::class, 'author_id'); } public function category(): BelongsTo { return $this->belongsTo(Category::class); } public function tags(): BelongsToMany { return $this->belongsToMany(Tag::class); } }