0๐
โ
My thanks to @James. Iโm saving the last ID of all fetched Comments + using a WHERE Query
I changed the Vue Method to:
url() {
this.page++;
return `${location.pathname}/comments?page=${this.page}&lastComment=${this.idOfLastComment}`;
},
And in my Controller:
/**
* Fetch all relevant comments.
*
* @param string $username
* @param Selllink $selllink
*/
public function index($username, $selllink)
{
$commentID = request('lastComment', $default = 0);
$filter = $commentID == 0 ? '>' : '<=';
return $selllink->sell->comments()
->where('id', $filter, $commentID)
->latest()
->paginate(10);
}
Works perfectly ๐
Source:stackexchange.com