0

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!

  • can you please show your view files – sumit Mar 14 '18 at 19:40
  • I agree with @sumit please include more details .. can you add your view and what does dd($member) output? – Hamza Mohamed Mar 14 '18 at 22:32
  • dd($member) output is correct and it returns proper data. In view file I am iterating through loop to display members. On evevt-home page it displays the member but if I click on 2nd page it appends the link in the URL as shown above... I am out so can't share the code now but can share tonight. Thanks – Kamlesh Gupta Mar 15 '18 at 04:32

0 Answers0