I am using laravel pagination but url of pagination is not relative and it appends the new url to previous url for example if my current url is "http://localhost:8080/event-home/1" then when I click on 2nd page it generates link as "http://localhost:8080/event-home/1#http://localhost:8080/event-home/1?page=2"
As you can see it appends to the previous url and therefore it does not return the next page. Actually the URL should be like "http://localhost:8080/event-home/1?page=2" Following is the code for the same
if (Session::get('event_id') != null){
$members = Event::find(Session::get('event_id'))->users()->orderBy('name','asc')->paginate(5);
if ($request->ajax()) {
if($request->page) {
return view('event.members', ['members' => $members]);
}
else
return view('event.event-home', ['members' => $members]);
}
Here is my view code:
@foreach($members as $member)
<div class="col-lg-3 col-md-4 col-xs-6 member" id="memberId_{{$member->id}}">
<div class="caption">
<a href="/profile/{{$member->id}}" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="{{url('images/users/'.$member->id.'/profile_image/'.$member->avatar_url)}}" alt="">
</a>
<center> <a href="/profile/{{$member->id}}"> {{$member->name }} {{$member->profiles->last_name}}</a></center>
</div>
</div>
@endforeach
{{ $members->links() }}
Thanks!