mardi 27 juin 2017

Laravel 5 pagination

I made pagination like in guides.I doing a search in db, and refer variable with data ti view.

public function search(Request $request)
{
    $products = DB::table('product')->where('number', 'like', $request->number.'%')->paginate(20);
    return view('site.content_layouts', [
        'products' => $products
    ]);
}

Here is part of my html file

 @foreach($products as $product)
                <form role="form" method="get" action="">
                <tr>
                    <input type="hidden" name = "id" value="">

                    <td></td>
                    <input type="hidden" name = "manufacturer" value="">

                    <td></td>
                    <input type="hidden" name = "number" value="">

                    <td></td>
                    <input type="hidden" name = "name" value="">

                    <td></td>
                    <input type="hidden" name = "quantity" value="">

                    <td></td>
                    <input type="hidden" name = "trader" value="">

                    <td></td>
                    <input type="hidden" name = "price" value="">

                    <td><input size="5px" type="text"  id="quantity_choose" name="quantity_choose" value="1"></td>

                    <td>
                        <p data-placement="top" data-toggle="tooltip" title="AddToCart">
                            <button class="btn btn-danger btn-xs" data-title="AddToCart" data-toggle="modal" data-target="#AddToCart" >
                                <span class="glyphicon glyphicon-trash">

                                </span>
                                </button>
                        </p>
                    </td>

                </tr>
                </form>
            @endforeach
            </tbody>
        </table>

First page displayed normally. But when I follow the links of other pages, there displayed first 5 lines of ALL my db, and created links to 61k pages.Not only lines what I search like in first page - its deduces all my db. Help me please) Where is a problem?

1)First page, where al is normally 2)Here I use link of second page



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire