yajra / laravel-datatables-ui
Laravel DataTables UI Preset
Fund package maintenance!
yajra
Patreon
www.paypal.me/yajra
Requires
- laravel/ui: ^2.0
- yajra/laravel-datatables-buttons: ^4.9
This package is auto-updated.
Last update: 2024-10-25 13:48:16 UTC
README
Laravel DataTables UI Preset to setup most of the scripts and css required for a DataTables powered projects.
Installation
You can install the package via composer:
composer require yajra/laravel-datatables-ui
Usage
Once the package has been installed, you may install the frontend scaffolding using the ui Artisan command:
// Generate basic scaffolding... php artisan ui dt // Generate login / registration scaffolding... php artisan ui dt --auth
Usage with DataTables Editor
If you have license and want to use Editor, you need to setup the following:
- Enable editor library on
bootstrap.js
require('datatables.net-editor-bs4');
- Use
laravel-datatables-assets
package instead ofbuttons.server-side.js
script onapp.js
.
//require('./vendor/buttons.server-side'); require('laravel-datatables-assets/js/dataTables.buttons');
- Add
postinstall
script on package,json
"scripts": { "dev": "npm run development", ..., "postinstall": "node ./node_modules/datatables.net-editor/install.js ./Editor.zip" },
- Download your copy of Editor Library JS + CSS file and save as
Editor.zip
. - Move
Editor.zip
to your project base directory. - Run
npm install && npm run dev
to compile changes.
Blade Directive @dataTable
To use @dataTable
blade directive, you need to firt setup the following on your layout file.
- Include
app.css
on your layout. - Include
app.js
on your layout. - Add
@stack('scripts')
afterapp.js
script include.
Example layout & page
resources/views/layouts/app.php
<!DOCTYPE html> <html> <head> <title>Laravel</title> <link rel="stylesheet" href="{{ mix('css/app.css') }}"> </head> <body> @yield('content') <script src="{{ mix('js/app.js') }}"></script> @stack('scripts') </body> </html>
Create your dataTables class. See https://yajrabox.com/docs/laravel-datatables/master/buttons-starter for details.
On your view:
@extends('layouts.app') @section('content') @dataTable @endsection
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email aqangeles@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.