Witajcie.
Mam taki kod:
class ForumCategory extends Model
{
use scopeActiveTrait;
protected $quarded = ['id'];
protected $fillable = ['company_id', 'enable', 'name', 'url_address', 'enable'];
public $timestamps = false;
public function themes()
{
return $this->hasMany('App\ForumPost', 'id_category', 'id')->where('parent_id', '=', null);
}
public function lastPost()
{
return $this->themes()->orderBy('id', 'desc')->first();
}
}
class ForumPost extends Model
{
use scopeActiveTrait;
protected $quarded = ['id'];
protected $fillable = ['company_id', 'id_category', 'parent_id', 'user_id', 'date', 'title', 'content', 'url_address', 'enable'];
public $timestamps = true;
protected $table = 'forum';
public function category()
{
return $this->belongsTo('App\ForumCategory', 'id_category');
}
public function author()
{
return $this->belongsTo('App\User', 'user_id');
}
public function postCount()
{
return $this->hasMany('App\ForumPost', 'parent_id', 'id')->where('parent_id', '!=', null)->count();
}
}
Po wywołaniu funkcji:
ForumCategory::with('themes')->orderBy('name', 'asc')->paginate(35);
Mam paginację dla kategorii.
W momencie gdy wyświetlam wyniki tej funkcji:
@foreach ($forums as $forum)
Welcome in {{ $forum->name }}<br/>
@foreach ($forum->themes as $post)
Post: {{ $post->title }}
@endforeach
<div class="paginationFormat"></div>
<div class="text-right">{{ $forums->links() }}</div>
@endforeach
Mogę wyświetlić paginację dla $forums.
Chciałbym dodatkowo wyświetlić paginację dla $post (danych z relacji). W jaki sposób można to zrobić?