Skip to content
Advertisement

How to fix laravel 8 UI paginate problem?

I had a problem while trying out the recently released laravel 8, I’m trying to find out what the changes are and how it works. When I did that I had a problem with the paginate laravel 8 UI getting messy and somehow it happened. Is there anyone who can help me? or have experienced the same thing?

Like this the view I got in laravel 8 Laravel 8 paginate UI

and this is the code I use “Index.blade.php”

@extends('layouts.app')

@section('title', 'Post')

@section('contents')

    <div class="container">
        <div class="row">
            @foreach ($posts as $post)
                <div class="col-md-4 mb-4">
                    <div class="row">
                        <div class="card mb-4">
                            <div class="card-header">
                                {{ $post->title }}
                            </div>
                            <div class="card-body">
                                {{ $post->body }}
                            </div>
                            <div class="card-footer">
                                {{ $post->created_at->diffForHumans() }}
                            </div>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
        <div class="d-felx justify-content-center">

            {{ $posts->links() }}

        </div>
    </div>

@endsection

the code I use for PostController

<?php

namespace AppHttpControllers;

use AppModelsPosts;
use IlluminateHttpRequest;

class PostsController extends Controller
{
    public function index()
    {
        $posts = Posts::latest()->paginate(6);
        // dd($post);
        return view('post.index', compact('posts'));
    }
}

Advertisement

Answer

I was having same issue.

Seems like in Laravel 8 more options were added how pagination can be displayed.

This instruction https://laravel.com/docs/8.x/pagination#using-bootstrap should help.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement