diff --git a/README.md b/README.md
index c4cefae..1db759b 100644
--- a/README.md
+++ b/README.md
@@ -6,27 +6,27 @@
This repo contains a Datatable that can render a filterable and sortable table. It aims to be very lightweight and easy to use. It has support for retrieving data asynchronously, pagination, permission check, role check, laravel policies and recursive searching in relations.
## Note
-Users who want to use the older version of this package, go to the [early version repo](https://github.com/ACFBentveld/Laravel-datatables). The ACFBentveld group is transferred to a new group called SingleQuote.
+Users who want to use the older version of this package, go to the [early version repo](https://github.com/ACFBentveld/Laravel-datatables). The ACFBentveld group has transferred to a new group called SingleQuote.
## Installation
-> The package is tested on laravel 5, 6 and 7
+> The package is tested on laravel 5.8.*, 6.* and 7.*
You can install the package via composer:
```bash
composer require singlequote/laravel-datatables
```
-## Whats new
-* You can use filters to add directly to your tableModel. Check it out [here](https://singlequote.github.io/Laravel-datatables/filters)
-* Column search fields. This makes it easy to search on a single column. Check it out here [here](https://singlequote.github.io/Laravel-datatables/table-models)
-
## Let's start
We wanted our code as clean as possible and use the same code more than once.
[See the Quick start docs here](https://singlequote.github.io/Laravel-datatables/)
+## Whats new
+* You can use filters to add directly to your tableModel. Check it out [here](https://singlequote.github.io/Laravel-datatables/filters)
+* Column search fields. This makes it easy to search on a single column. Check it out here [here](https://singlequote.github.io/Laravel-datatables/table-models)
+
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
diff --git a/composer.json b/composer.json
index bb82667..05c7934 100644
--- a/composer.json
+++ b/composer.json
@@ -9,17 +9,17 @@
],
"homepage": "https://github.com/singlequote/Laravel-datatables",
"license": "MIT",
- "version": "3.0.39",
+ "version": "3.1.0",
"authors": [
{
"name": "Wim Pruiksma",
"email": "wim@quotec.nl",
"homepage": "https://www.quotec.nl/",
- "role": "CEO"
+ "role": "Software Architect"
}
],
"require": {
- "php": "^7.1",
+ "php": "^7.4",
"singlequote/laravel-cacher": "^0.0"
},
"require-dev": {
diff --git a/docs/fields.md b/docs/fields.md
index 7fdae95..f73382f 100644
--- a/docs/fields.md
+++ b/docs/fields.md
@@ -12,10 +12,11 @@ Field classes can be used to change the behaviour of the columns.
- [Label](https://singlequote.github.io/Laravel-datatables/fields/label)
- [Middleware](https://singlequote.github.io/Laravel-datatables/fields/middleware)
- [Number](https://singlequote.github.io/Laravel-datatables/fields/number)
+- [Checkbox](https://singlequote.github.io/Laravel-datatables/fields/checkbox)
### Example
-Below is a simple example on how to use fields inside your [tableModel](https://singlequote.github.io/Laravel-datatables/table-models).
+Below is a simple example on how to render fields for your table [tableModel](https://singlequote.github.io/Laravel-datatables/table-models).
In this example we are going to add an edit button and format a date string.
Always add the field classes to the `fields` method inside your [tableModel](https://singlequote.github.io/Laravel-datatables/table-models).
diff --git a/docs/fields/checkbox.md b/docs/fields/checkbox.md
new file mode 100644
index 0000000..5211434
--- /dev/null
+++ b/docs/fields/checkbox.md
@@ -0,0 +1,61 @@
+# Checkbox
+The checkbox class replaces a value from the results with an default html checkbox.
+
+[Go back to fields](https://singlequote.github.io/Laravel-datatables/fields)
+
+### Default checkbox
+Below is an example on how to generate a default html input with type checkbox.
+
+```php
+Checkbox::make('email_verified_at')
+```
+The checkbox field can be extended with a lot of available methods. Such as classes and routes.
+
+#### Class
+Add dom classes to the checkbox
+
+```php
+Checkbox::make('email_verified_at')->class('my-custom-checkbox')
+//
+```
+
+#### Icon
+Add an icon before the checkbox
+
+```php
+Checkbox::make('email_verified_at')->icon('material-icons', optional 'edit'),
+// edit
+
+Checkbox::make('email_verified_at')->icon('fa fa-edit'),
+//
+```
+
+#### Checked
+The checkbox can set to checked when passing a value that is not null, false or int 0.
+
+```php
+Checkbox::make('email_verified_at')->checked(true)
+//
+Checkbox::make('email_verified_at')->checked('deleted_at') //when value is null => false,
+//
+```
+
+
+### Add onclick
+The onclick method can be used to trigger an event.
+
+```php
+Checkbox::make('email_verified_at')->onclick("$('form').submit()"),
+
+//
+```
+
+### Full example
+```php
+Checkbox::make('email_verified_at')->class('my-checkbox')->checked('email_verified_at !== null')->name('email_verified_at')->data(['user_id' => 'id'])->onclick("updateEmailVerifiedAt(this)"),
+
+```
+
+```html
+
+```
diff --git a/docs/table-models.md b/docs/table-models.md
index df803bd..4424a31 100644
--- a/docs/table-models.md
+++ b/docs/table-models.md
@@ -59,7 +59,7 @@ Inside the `columns` property you define your table columns. By defaut the table
"class" => "td-actions", //this is the td class
"searchable" => true, //set the column to be searchable
"orderable" => true //set the column to be orderable
- "columnSearch" => false, //this creates a search input for the column
+ "columnSearch" => false, //this generates a search input below the column header
]
];
```
diff --git a/src/Controllers/DataTable.php b/src/Controllers/DataTable.php
index 5b4a088..70630f7 100644
--- a/src/Controllers/DataTable.php
+++ b/src/Controllers/DataTable.php
@@ -228,7 +228,6 @@ function ($item, $key) use ($build) {
$collection = $this->encryptKeys($middlewared->unique()->values()->toArray());
-
$data['recordsTotal'] = $count;
$data['recordsFiltered'] = $count;
$data['data'] = $collection ?? [];
diff --git a/src/Controllers/Field.php b/src/Controllers/Field.php
index f580cb7..514f991 100644
--- a/src/Controllers/Field.php
+++ b/src/Controllers/Field.php
@@ -121,7 +121,7 @@ public function permission(string $permissions)
$required = str_replace([', ', ' ,', ', ' , ' | ', ' |', '| '], ',', $permissions);
$else = explode('|', $required);
- foreach ($else as $key => $item) {
+ foreach ($else as $item) {
$this->permissions[] = explode(',', $item);
}
@@ -139,7 +139,7 @@ public function role(string $roles)
$required = str_replace([', ', ' ,', ', ' , ' | ', ' |', '| '], ',', $roles);
$else = explode('|', $required);
- foreach ($else as $key => $item) {
+ foreach ($else as $item) {
$this->roles[] = explode(',', $item);
}
@@ -169,7 +169,7 @@ public function build()
*/
public function columnPath(string $string = null) : string
{
- $explode = explode('.', $this->overwrite ?? $this->column);
+ $explode = explode($this->overwrite ?? $this->column, '.');
array_pop($explode);
$add = $string ? ".$string": "";
if (count($explode) === 0) {
diff --git a/src/DataTable.php b/src/DataTable.php
index 3013a0a..40c89e5 100644
--- a/src/DataTable.php
+++ b/src/DataTable.php
@@ -95,7 +95,7 @@ private function parseFilters(string $encoded): array
$filters = [];
- foreach ($explode as $index => $value) {
+ foreach ($explode as $value) {
$name = Str::before($value, ';');
$multiple = Str::contains($value, ';m*');
$value = Str::after($value, '*');
@@ -252,7 +252,7 @@ private function checkDefs()
/**
* Render the defs
- * THe defs define the columns behaviour
+ * The defs define the columns behaviour like rendering Fields and parsing middlewares
*
*/
private function buildDef()
diff --git a/src/Fields/Multiple.php b/src/Fields/Multiple.php
index a98ab70..5be5c2c 100644
--- a/src/Fields/Multiple.php
+++ b/src/Fields/Multiple.php
@@ -119,7 +119,7 @@ public function count(\Closure $closure)
/**
* Set the implode fields
*
- * @param string $column
+ * @param string $separate
* @return $this
*/
public function implode(string $separate = ", ")
diff --git a/src/resources/views/fields/checkbox.blade.php b/src/resources/views/fields/checkbox.blade.php
index 3dbe37c..3876143 100644
--- a/src/resources/views/fields/checkbox.blade.php
+++ b/src/resources/views/fields/checkbox.blade.php
@@ -12,7 +12,7 @@
-->