Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

php - How to correct scattered pagination links and objects view in browser while using pagination() function in Laravel 8

I am working on Laravel 8 framework, PHP 8 and MariaDB 10.4.17.

I am using paginate() feature in controller class and {{$variable->links()}} in .blade.php view file.

When testing the outcome on the browser, I am getting the paginator links and objects scattered.

Here is how I use paginate() in controller class :

class Homepage extends Controller
{
    public function index(){

        $data['articles']=Article::orderBy('created_at','DESC')->paginate(1);

        return view('front.homepage',$data);

    }

Here is how I call pagination in my .blade.php view file :

{{$articles->links()}}

Finally, this is the scattered view I get in browser:

browser snapshot

I would be happy to hear from you, if you have any idea why such untidiness occurs and how to correct it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem was that, I am using Bootstrap and Laravel 8 is using TailwindCss pagination by default. Therefore adding this:

 use IlluminatePaginationPaginator;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Paginator::useBootstrap();
}

to the AppProvidersAppServiceProvider class solves the problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...