alkhatibdev/inertia-pagination

Laravel Inertia Pagination, is a Laravel package for generating inertia pagination vue component, designed with TailwindCSS.

0.0.1 2023-11-30 22:41 UTC

This package is auto-updated.

Last update: 2024-06-06 11:32:08 UTC


README

Latest Version MIT Licensed

Introduction

Laravel Inertia Pagination, is a Laravel package for generating inertia pagination vue component, designed with TailwindCSS.

Installation

install via composer

composer require alkhatibdev/inertia-pagination

Publish

php artisan vendor:publish --tag=inertia-pagination

Usage

Assume this is your inertia response:

// App\Http\Controllers\PostController

public function index() 
{
    return Inertia::render('Post/Index', [
        'posts' => Post::select([
            "id", "title", "description"
        ])->paginate(10),
    ]);
}

Within your inertia page, just import IPagination vue component, then pass your paginated collection links to it.

// resources/js/Pages/Post/Index.vue 

<script setup>
    import IPagination from '@/Components/vendor/InertiaPagination/IPagination.vue'

    defineProps({
        posts: Object
    })
</script>

<template>
    ...
        <div v-for="post in posts.data" :key="post.id">...</div>

        <!-- Use component here, and pass the links array -->
        <IPagination :links="posts.links" />
    
    ...
</template>

Customization

Coming soon..

License

Language Switcher is open-sourced software licensed under the MIT license.