fixing thsu frontend views
This commit is contained in:
@@ -4,6 +4,9 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -60,4 +63,20 @@ class Forum extends Model
|
||||
{
|
||||
return $this->hasMany(Thread::class);
|
||||
}
|
||||
|
||||
public function posts(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Post::class, Thread::class, 'forum_id', 'thread_id');
|
||||
}
|
||||
|
||||
public function latestThread(): HasOne
|
||||
{
|
||||
return $this->hasOne(Thread::class)->latestOfMany();
|
||||
}
|
||||
|
||||
public function latestPost(): HasOneThrough
|
||||
{
|
||||
return $this->hasOneThrough(Post::class, Thread::class, 'forum_id', 'thread_id')
|
||||
->latestOfMany();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user