lundi 15 août 2016

Pagination not working in laravel 5.1 gives me all the data

I am currently doing a project called Doctor Management System.In this project I am stuck because my pagination is not working.I want to show 2 hospital info per page but it gives me all the data.Please help me solving this. My Route file is

Route::get('/district/hospital/hospital_info/{id}', array('as' =>'hospital_info' ,'uses' => 'UserController@hospital_info'));

My controller is

public function hospital_info($id)
    {
        $divisions = Division::all();
         $division=Division::find($id); 

         $district=District::find($id); 
         $category=Category::find($id);
         $hospital=Hospital::find($id);
         $hospitals = $hospital->paginate(2);

        return view('users.hospital_info')
                    ->with('divisions',  $divisions)
                    ->with('division', $division)
                    ->with('district', $district)
                    ->with('category',$category)
                    ->with('hospitals',$hospitals);
    }

My view file is

<?php $active="hospital"; ?>
@extends('layouts.dashboard')
@section('content') 

    <section id="blog" class="container">
        <div class="center">
            <h2>Hospital Information</h2>
            <h3 class="lead">The government approved a renowned hospital and improved quality of service address , doctor , patient viewing time, bed , pathological tests in various subjects including costs and find the information here .<br> The bed and cabin bookings online , pathological tests , the doctor can be a serial for the meeting from the app .</h3>
        </div>

        <div class="blog">
            <div class="row">
                 <div class="col-md-12">
                    <div class="blog-item">
                        <div class="row">
                            @foreach($district->hospital as $hospital)  
                                <div class="col-xs-12 col-sm-4 blog-content">
                                </div>

                                    <div class="col-xs-12 col-sm-6 blog-content">
                                        <h2></h2>
                                        <h5>Address : </h5> 
                                        <h5>Ownership : </h5>
                                        <h5>Start of activities : </h5>
                                        <h5>Number of beds : </h5>
                                        <h5>Number of doctor : </h5>
                                        <h5>Phone No : </h5>
                                    </div>

                                <div class="col-xs-12 col-sm-2 blog-content">
                                    <h2><a href="#">Share</a></h2>
                                    <ul class="social-share">
                                            <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                                            <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                                            <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                                            <li><a href="#"><i class="fa fa-skype"></i></a></li>
                                        </ul>
                                        <br><br>

                                    <a class="btn btn-success readmore" href="{!! URL::route('doctor_list') !!}">Doctor List</a>
                                </div>
                                @endforeach 
                            </div>

                    </div><!--/.blog-item-->
                    @if($hospitals->lastPage() > 1)

                        <ul class="pagination pagination-lg">
                        {!! $hospitals->render() !!}

                        </ul><!--/.pagination-->
                    @endif

                </div><!--/.col-md-8-->

            </div><!--/.row-->
        </div>
    </section><!--/#blog-->
@stop



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire