lots of improvements
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user