You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-39Lines changed: 61 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,18 @@
2
2
3
3
**About**
4
4
5
-
This bundle is created to handle server-side works of DataTables Jquery Plugin (http://datatables.net) by using Eloquent ORM or Fluent Query Builder.
5
+
This bundle is created to handle the server-side processing of the DataTables Jquery Plugin (http://datatables.net) by using Eloquent ORM or Fluent Query Builder.
6
6
7
7
### Feature Overview
8
8
- Supporting Eloquent ORM and Fluent Query Builder
9
-
- Adding or editing content of columns and removing columns
9
+
- Adding or editing the contents of columns and removing columns
10
10
- Templating new or current columns via Blade Template Engine
11
11
- Customizable search in columns
12
12
13
13
14
14
### Installation
15
15
16
-
Add the `bllim/datatables`under the `require` key after that run the`composer update`.
16
+
Require `bllim/datatables`in composer.json and run `composer update`.
17
17
18
18
{
19
19
"require": {
@@ -24,7 +24,7 @@ Add the `bllim/datatables` under the `require` key after that run the `composer
24
24
...
25
25
}
26
26
27
-
Composer will download the package. After package downloaded, open "app/config/app.php" and edit like below:
27
+
Composer will download the package. After the package is downloaded, open `app/config/app.php` and add the service provider and alias as below:
It is very simple to use this bundle. Just create your own fluent query object or eloquent object without getting results (that means don't use get(), all() or similar methods) and give it to Datatables.
50
50
You are free to use all Eloquent ORM and Fluent Query Builder features.
51
51
52
-
It is better, you know these:
53
-
- When you use select method on Eloquent or Fluent Query, you choose columns
54
-
- You can easily edit columns by using edit_column($column,$content)
55
-
- You can remove any column by using remove_column($column) method
56
-
- You can add columns by using add_column($column_name, $content, $order)
57
-
- You can use Blade Template Engine in your $content values
58
-
- The name of columns is set by returned array.
59
-
- That means, for 'posts.id' it is 'id' and also for 'owner.name as ownername' it is 'ownername'
60
-
- You can set the "index" column (http://datatables.net/reference/api/row%28%29.index%28%29) using set_index_column($name)
61
-
- You can add search filters for each column to override default search functionality
62
-
52
+
Some things you should know:
53
+
- When you call the `select` method on Eloquent or Fluenty Query, you choose columns.
54
+
- Modifying columns
55
+
- You can easily edit columns by using `edit_column($column, $content)`
56
+
- You can remove any column by using `remove_column($column)`
57
+
- You can add columns by using `add_column($column_name, $content, $order)
58
+
- You **can** use the Blade Template Engine in your `$content` values.
59
+
- You may pass a function as the $content to the `add_column` or `edit_column` calls. The function receives a single parameter: the query row/model record. (see Example 2)
60
+
- The column identifiers are set by the returned array.
61
+
- That means, for `posts.id` the relevant identifier is `id`, and for `owner.name as ownername` it is `ownername`
62
+
- You can set the "index" column (http://datatables.net/reference/api/row().index()) using `set_index_column($name)`
63
+
- You can add customized search filters for each column to override the default search functionality
64
+
- You can call `make(true)` to return an array of objects instead of an array of arrays. (see Example 4)
return "The author of this post is {$row->ownername}";
88
+
})
89
+
->remove_column('id')
90
+
->make();
92
91
93
-
**Notice:** If you use double quotes while giving content of add_column or edit_column, you should escape variables with backslash (\) else you get error. For example:
92
+
**Notice:** If you use double quotes while assigning the $content in an `add_column` or `edit_column` call, you should escape variables with a backslash (\\) to prevent an error. For example:
94
93
95
-
edit_column('id',"- {{ \$id }}") .
94
+
edit_column('id', "{{ \$id }}") .
96
95
97
96
98
-
**Example 3:**
97
+
**Example 3: Using filter_column**
99
98
100
99
$clients = Client::select(array(
101
100
'Client.id',
@@ -119,18 +118,41 @@ It is better, you know these:
*`$column_name` - the column name that search filter is be applied to
124
123
*`$method` - can be any of QueryBuilder methods (where, whereIn, whereBetween, having etc.).
125
124
* Note: For global search these methods are automaticaly converted to their "or" equivalents (if applicable, if not applicable, the column is not searched).
126
-
* If you do not want some column to be searchable in global search set the last where's parameter to "and" (see line 17 in example above). Doing this way the filter cannot be switched into its "or" equivalent therefore will not be searched in global search .
127
-
*`$param_1 ... $param_n` - these are parameters that will be passed to the selected where function. Possible types:
125
+
* If you do not want some column to be searchable in global search, set the last parameter to "and" (see line 17 in example above). Doing this, the filter cannot be switched into its "or" equivalent and therefore will not be searched in global search .
126
+
*`$param_1 ... $param_n` - these are parameters that will be passed to the selected where function (`$method`). Possible types:
128
127
*`string`
129
-
*`DB::raw()` - The DB::raw() can output literaly everything into the query, for example subqueries or branching if you need some really sophisticated wheres.
128
+
*`DB::raw()` - The DB::raw() can output literaly everything into the query. For example, subqueries or branching if you need some really sophisticated wheres.
130
129
*`function` - or any other callable
131
-
*`array` of any above
132
-
* the search value is passed to the query by `$1` string placed anywhere in parameters. If callable (function) is used the searched value is passed to callable as first parameter. The callable must returns value that will be passed to the QueryBuilder's function.
130
+
*`array` of any of the above
131
+
* The search value is passed to the query by the string `$1` placed anywhere in parameters. If a callable (function) is used the searched value is passed to callable as first parameter the first parameter (again see line 17).
132
+
* The callable must return a value that will be passed to the QueryBuilder's function.
0 commit comments