It's easier than I thought. the key is to use the reverse() method on the collection in the foreach loop
CommentComponent.php
use WithPagination;
public $perPage = 5;
public function loadMore() {
$this->perPage = $this->perPage + 5;
}
public function render() {
$comments = Comment::latest()->paginate($this->perPage);
return view('livewire.comment-component', ['comments' => $comments]);
}
comment-component.blade.php
<div>
<div class="comments">
@if($comments->hasMorePages())
<button wire:click="loadMore()" type="button">Show more</button>
@endif
@foreach($comments->reverse() as $comment)
<div>....</div>
@endforeach
</div>
<form ..... class="comment-form">
<textarea ...></textarea>
<button type="submit">Submit</button>
</form>
</div>