Suganya Rajasekar
Suganya Rajasekar

Reputation: 684

How to set pagiantion links in laravel

View

$aHotelRooms = DB::table('abserve_hotels')->paginate(3);

@foreach($aHotelRooms as $aHotelRoom)
@endforeach
<div class="pagination">
<?php
echo $aHotelRooms->appends('aHotelRooms')->render(); 
?>

Here pagination shows the lists according to what I gave in paginate()..

But when I click the links in that pagination..It seems to be an Object not found 404 error..

What should I do for this..

Regards Suganya,

Upvotes: 0

Views: 268

Answers (3)

user2094178
user2094178

Reputation: 9444

When using xampp you can proceed like the following:

{!! $aHotelRooms->path('')->appends('aHotelRooms')->render() !!}

If path('') doesn't work, you can also try path('/').

I always had to use this hack in xampp.

Upvotes: 1

Hiren Gohel
Hiren Gohel

Reputation: 5042

Try this:

$aHotelRooms = DB::table('abserve_hotels')->simplePaginate(15);

<div class="container">
    @foreach ($aHotelRooms as $rooms)
         {{ $rooms->name //define here what you need }}
    @endforeach
</div>

{!! $aHotelRooms->links() !!}

I am new to laravel. Hope this helps you...!!

Upvotes: 0

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

You have wrong Laravel settings. You should point your web server (for example, Apache) to the public directory which is inside you Laravel project's root directory. That's why your links are broken.

For example, if your Sugan directory is in c:\MySites\, you must set up c:\MySites\Sugan\travelz\public directory as root directory.

Update

To chage root directory in XAMPP:

  • Go to C:\xampp\apache\conf\httpd.conf
  • Open httpd.conf
  • Find tag DocumentRoot "C:/xampp/htdocs"
  • Edit tag to DocumentRoot "C:/xampp/htdocs/myproject/web"
  • Now find tag < Directory > and change it to < Directory "C:/xampp/htdocs/myproject/web" >
  • Restart Your Apache

Upvotes: 1

Related Questions