Skip to content

Commit

Permalink
Feature: Added Suport For Column Wise Search And Gloabal Search , Fil…
Browse files Browse the repository at this point in the history
…tering Data From Frontend, Server Side Export To Different File Formats
  • Loading branch information
iYogesharma committed Oct 21, 2024
1 parent 10fafa3 commit da7f3f9
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 274 deletions.
85 changes: 64 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,89 @@
<p align="center">
<img src="https://github.com/iYogesharma/datatable-laravel/blob/master/logo.png" /></p>

[![Latest Stable Version](https://poser.pugx.org/iyogesharma/datatable-laravel/v/stable)](https://packagist.org/packages/iyogesharma/datatable-laravel)
[![Total Downloads](https://poser.pugx.org/iyogesharma/datatable-laravel/downloads)](https://packagist.org/packages/iyogesharma/datatable-laravel)
[![License](https://poser.pugx.org/iyogesharma/datatable-laravel/license)](https://packagist.org/packages/iyogesharma/datatable-laravel)

# jQuery Datatables For Laravel 5.x
# jQuery Datatables For Laravel
A simple package to ease datatable.js server side operations

This package is created to handle [server-side](https://www.datatables.net/manual/server-side) and [client-side](https://www.datatables.net/manual) works of [DataTables](http://datatables.net) jQuery Plugin via [AJAX option](https://datatables.net/reference/option/ajax) by using Eloquent ORM, Query Builder or Collection.


## datatable-laravel 2.0
## datatable-laravel 4.x

Version 2.0 continues the improvements in version 1.0.3 by introducing some new functions , improved code structure and various bug fixes.
Version 4.x continues the improvements in version 3.x by introducing some new features

## New

Introduced three new functions for the case if you know
query is instance of which class. Currently supported include:
Eloquent Query Builder, Database Query Builder and Eloquent Collection

```php

echo datatable()->eloquent(User::query())->init();
echo datatable()->collection(User::query())->init();
echo datatable()->queryBuilder(User::query())->init();

```
- Added support for select raw queries

- Auto guess column names if no columns are provided in request

- Auto guess column names if * is provided in column names

- Added support for group by and havig clause

- Example
```php
echo datatable(User::select('users.name','users.email','users.contact_no','users.role_id')
->selectRaw("
Max(id) as total
")
->groupBy('users.name', 'users.email', 'users.contact_no'))->init();

echo datatable(User::select('users.*'))->init();
```


- Added Support For Data Filtering From Client Side
- Added Column Wise Search Query Support Using Below Api
- Example
```json
{
"columns": [
{
"data": "name",
"name": "name",
"searchable": true,
"orderable": true,
"search": {
"value": "",
"regex": false
}
}
],
"start": 0,
"length": 10,
"search": {
"value": "Yoges",
"regex": false
},
"filters": {
"role_id" : [1,2],// role id in 1,2
"created_at": [date1, date2], // createde at is between date1 and date2,
"name": "iyogesh" // where name = iyogesh
}
}

```

## Modified

Modified make and datatable function . Second parameter here is boolean
with default to false indicate whether you want json response or not.
If you don't pass second parameter then you need to use init() function
as we are using in previous version.
Modified datatable function to support server side export to xls,csv and json

```php
You just need to pass 2 new arguments in query-string/body `export` and ` ext `

echo datatable()->make(User::query(),true);
echo datatable(User::query(),true);
if ` export = true ` it will return download file response
for `ext` default value is `xlsx`

```javascript
https://datatable-url?export=true&ext=xlsx
```



## Using Helper Function

```php
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"datatable",
"laravel"
],
"version": "3.6.2",
"version": "4.0",
"license": "MIT",
"authors": [{
"name": "Yogesh Sharma",
Expand Down Expand Up @@ -50,7 +50,7 @@
}
},
"branch-alias": {
"dev-master": "3.x-dev"
"dev-master": "4.x"
}
}
}
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit da7f3f9

Please sign in to comment.