Answer the question
In order to leave comments, you need to log in
Why is laravel not creating pagination?
I tried to create pagination on a separate site according to the official article on laravel.com, and I succeeded. I tried to do the same on my site, it did not work.
I have a Product model with the following parameters:
class Product extends Model
{
protected $table = 'products';
protected $fillable = [
'title',
'description',
'full_description',
'author'
];
}
Route::get('/', function(){
$products = App\Product::paginate(10);
return View::make('index')->with('products', $products);
});
<div class="container-fluid">
<div class="row">
@foreach( $products as $product )
<div class="col s12 m6 l4">
<div class="card">
<div class="card-image">
<img src="img/item-img-5.png" alt="">
<div class="card-title amber-text darken-2-text ">{!! Html::linkRoute('product.show', $product->title, array($product->id)) !!}</div>
</div>
<div class="card-content">
<p>{{ $product->description }}</p>
</div>
<div class="card-action amber-text darken-2-text">
{!! Html::linkRoute('product.edit', 'Редактировать', array($product->id)) !!}
{!! Form::open(['route' => ['product.destroy', $product->id], 'method' => 'delete']) !!}
<input type="submit" value="Удалить" />
{!! Form::close() !!}
<div class="pull-right"><em>{{'Опубликовал - ' . $product->author }}</em></div>
</div>
</div>
</div>
@endforeach
</div>
</div>
{!! $products->render() !!}
Answer the question
In order to leave comments, you need to log in
Let me clarify a little: are you sure that you have more than 10 products in your database?
If you are using Laravel 4 then instead of
{!! $products->render() !!}need
{{$products->links()}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question