2016-07-26 10 views
0

laravelページネーションを使用しています。次のページまたはページ番号をクリックすると、何も起こりません。 コントローラ機能ページ番号をクリックするとページネーションが機能しない

public function getIndex() 
{ 
    $articles = Inspector::paginate(15); 
    return view('admin.inspector.test', compact('articles')); 
} 

ビューファイル

 <table class="table table-bordered" id="mytable"> 
         <thead> 
          <tr> 
           <th>Sr. No.&nbsp;</th> 
           <th>Email</th> 
          </tr> 
         </thead> 
         <tbody> 
          @foreach ($articles as $article) 
          <tr> 
          <td>{{ $article->id }}</td> 
          <td>{{ $article->email }}</td> 
          </tr> 
          @endforeach 
         </tbody> 
        </table> 
        {!! $articles->render() !!} 

すべてのヘルプははるかに高く評価されたアクションの呼び出し中...おかげで...

+0

エラーは何ですか?あなたは '{!! –

答えて

-2
public function getIndex() 
{ 
    return view('admin.inspector.test'); 
} 

だけのビューを返します。コントローラーからデータを送信しないでください。ビューがロードされるときに ビューをロードするだけで、ページ接続方式でdb接続をフェッチします。ページ分割を次のようにレンダリングします

<?php $articles = DB::connection('table_name')->where('if any condition')->get(); ?> 
    <table class="table table-bordered" id="mytable"> 
          <thead> 
           <tr> 
            <th>Sr. No.&nbsp;</th> 
            <th>Email</th> 
           </tr> 
          </thead> 
          <tbody> 
           @foreach ($articles as $article) 
           <tr> 
           <td>{{ $article->id }}</td> 
           <td>{{ $article->email }}</td> 
           </tr> 
           @endforeach 
          </tbody> 
         </table> 
         {!! $articles->render() !!} 
+0

もう少し詳しいことを教えてください...私がビューでデータを返さない場合、どのようにデータを取得する必要がありますか? dbから! – Aamir

+1

あなたの答えのために投票してください – mydo47

+0

あなたは何をすることができるかは、ビュー自体にdb接続を実行することです...それを試してみてください... –

関連する問題