2016-05-02 6 views
0

ページごとに1行を表示する必要があります。 この私のcontollerクラスコードページの追加方法larvel 5

public function showcontent($id) 
{ 
    $story=storybook::find($id); 
    $content=storycontent::where('titleid', $story['id'])->paginate(1); 
    //return $content; 
    return view('storyBook/viewStory',compact('story','content')); 
} 

私は唯一の1行目を取得

ここで
@foreach($content as $content) 
      <?php $a=null; ?> 
      <?php $b=null; ?> 

       <?php $a=$content->file1; ?> 
       <?php $b=$content->file2; ?> 

      <table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px"> 
       <tr> 
        <td style="width: 340px"><img src="/{{$a}}" alt="Mountain View" style="width:330px;height:300px;"></td> 
        <td style="width: 340px"><img src="/{{$b}}" alt="Mountain View" style="width:330px;height:300px;"></td> 
       </tr> 
      </table> 
      <br> 
     @endforeach 

この私のビュークラスのコードは、表示されていない残りの行... 私は改ページを追加する方法がわかりません。

+0

ページあたり1行だけですか? –

+0

私は$ content..butのために複数の行を取得しますが、ページごとに1行を表示する必要があります。 – pinkyrox

答えて

0

@foreach($content as $content)

例えばVARSの命名を変更するすべてのだから、最初:

@foreach($content as $entry) 
    <table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px"> 
     <tr> 
      <td style="width: 340px"><img src="/{{$entry->file1}}" alt="Mountain View" style="width:330px;height:300px;"></td> 
      <td style="width: 340px"><img src="/{{$entry->file2}}" alt="Mountain View" style="width:330px;height:300px;"></td> 
     </tr> 
    </table> 
    <br> 
@endforeach 

$content->links() 

あなたは、私は、foreachループの後$content->links()を追加しました見ることができるように。これはページ分割ナビゲーションを印刷するPaginatorのメソッドです。

関連する問題