PHPackages                             gmlo89/datatable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gmlo89/datatable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gmlo89/datatable
================

DataTable / Laravel

1292[1 issues](https://github.com/gmlo89/datatable/issues)Vue

Since Dec 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/gmlo89/datatable)[ Packagist](https://packagist.org/packages/gmlo89/datatable)[ RSS](/packages/gmlo89-datatable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![GitHub All Releases](https://camo.githubusercontent.com/34c0a71dc09c7d052c0dd8ea66cc9388670470c92c34e297a4c37224784644d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f676d6c6f38392f646174617461626c652f746f74616c)](https://camo.githubusercontent.com/34c0a71dc09c7d052c0dd8ea66cc9388670470c92c34e297a4c37224784644d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f676d6c6f38392f646174617461626c652f746f74616c)

DataTable &amp; Searchable Trait
================================

[](#datatable--searchable-trait)

### Installation

[](#installation)

Run composer

```
composer require gmlo89/datatable @dev
```

Publish the component to add on your js

```
php artisan vendor:publish --provider="Gmlo\DataTable\ServiceProvider" --tag="vue-components"
```

Import on your js file

```
require('./vendor/datatable/app');
```

You require install:

```
    npm install vue --save
    npm install vuetify@1.5.22 --save

```

DataTable
---------

[](#datatable)

VueJs DataTable for Laravel 6

### Example on FrontEnd

[](#example-on-frontend)

```

         Products

            Detalles

```

### Backend

[](#backend)

```
    $query = Product::join('categories', 'products.category_id', '=', 'categories.id')
        ->join('brands', 'products.brand_id', '=', 'brands.id')
        ->selectRaw('products.*, categories.name as category_name, brands.name as brand_name');

    return dataTable()->query($query)
            ->setFilters(
                'categories.name', 'products.name',
                'products.code', 'products.ean',
                'products.upc', 'products.part_number',
                'products.model', 'brands.name'
            )
            ->configColumn('price', function($value, $row){
                return '$' . number_format($value, 2) . ' ' . $row->currency;
            })
            ->get();
```

Searchable Trait
----------------

[](#searchable-trait)

Add the trait to your model and the attribute "searcheable" with the fields to search.

```
