lots of improvements
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ForumTopic extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'thread_id',
|
||||
'user_id',
|
||||
'title',
|
||||
'content',
|
||||
'is_pinned',
|
||||
'last_activity_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_pinned' => 'boolean',
|
||||
'last_activity_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the thread that owns the topic.
|
||||
*/
|
||||
public function thread()
|
||||
{
|
||||
return $this->belongsTo(ForumThread::class, 'thread_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns the topic.
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the posts for the topic.
|
||||
*/
|
||||
public function posts()
|
||||
{
|
||||
return $this->hasMany(ForumPost::class, 'topic_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user