larapeak / inertiajs-data-tables
This is my package InertiajsDataTables
Fund package maintenance!
larapeak
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:Vue
Requires
- php: ^8.0
- illuminate/contracts: ^8.37
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- brianium/paratest: ^6.2
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2025-03-26 01:23:59 UTC
README
Create Data Tables in Laravel with Ease!
This package provides a trait that will generate a datatable for your model. It also provides Vue components that you can use with Inertiajs.
Installation
You can install the package via composer:
composer require larapeak/inertiajs-data-tables
You can publish the Vue components with following command:
php artisan vendor:publish --provider="Larapeak\InertiajsDataTables\InertiajsDataTablesServiceProvider" --tag="assets"
The Vue components will be published in:
resources\js\Shared\DataTables
Usage
Your Eloquent models should use the Larapeak\InertiajsDataTables\HasSorting
trait.
Here's an example of how to implement the trait:
namespace App\Models; use Larapeak\InertiajsDataTables\HasSorting; use Illuminate\Database\Eloquent\Model; class YourEloquentModel extends Model { use HasSorting; public $sortables = [ 'field1', 'field2', 'field3' ] }
On your Vue page you can use the DataTable component like this:
<template> <data-table :tableData:"data" :tableFields="tablefields" :filters="filters" model="posts" slug></data-table> </template> <script> import DataTable from '@/Shared/DataTables/DataTable' export default { components: { DataTable, }, props: { data: Array, filters: Object, }, data() { return { tableFields: [ { id: 'field1', name: 'Field1', type: 'text', }, { id: 'field2', name: 'Field2', type: 'text', }, { id: 'field3', name: 'Field3', type: 'text', } ] } } } </script>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.