Files

60 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2026-02-22 20:02:34 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ForumThread extends Model
{
protected $fillable = [
'category_id',
'user_id',
'title',
'slug',
'is_sticky',
'is_locked',
'views',
'last_activity_at',
];
protected $casts = [
'is_sticky' => 'boolean',
'is_locked' => 'boolean',
'last_activity_at' => 'datetime',
];
/**
* Get the category that owns the thread.
*/
public function category()
{
return $this->belongsTo(ForumCategory::class, 'category_id');
}
/**
* Get the user that owns the thread.
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get the topics for the thread.
*/
public function topics()
{
return $this->hasMany(ForumTopic::class, 'thread_id');
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
}