yajra/laravel-datatables-ui

Laravel DataTables UI Preset

v0.3.0 2020-06-25 03:08 UTC

This package is auto-updated.

Last update: 2024-11-25 14:00:47 UTC


README

Latest Version on Packagist Total Downloads

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:

  1. Enable editor library on bootstrap.js
require('datatables.net-editor-bs4');
  1. Use laravel-datatables-assets package instead of buttons.server-side.js script on app.js.
//require('./vendor/buttons.server-side');
require('laravel-datatables-assets/js/dataTables.buttons');
  1. Add postinstall script on package,json
    "scripts": {
        "dev": "npm run development",
        ...,
        "postinstall": "node ./node_modules/datatables.net-editor/install.js ./Editor.zip"
    },
  1. Download your copy of Editor Library JS + CSS file and save as Editor.zip.
  2. Move Editor.zip to your project base directory.
  3. 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.

  1. Include app.css on your layout.
  2. Include app.js on your layout.
  3. Add @stack('scripts') after app.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.