@@ -31,7 +31,7 @@ |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @return bool |
|
| 34 | + * @return string |
|
| 35 | 35 | */ |
| 36 | 36 | public function isAscending() |
| 37 | 37 | { |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use OpenSkill\Datatable\Providers\Provider; |
| 8 | 8 | use OpenSkill\Datatable\Versions\VersionEngine; |
| 9 | 9 | use OpenSkill\Datatable\Views\DatatableView; |
| 10 | -use Symfony\Component\VarDumper\Cloner\Data; |
|
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Class Datatable |
@@ -55,6 +55,6 @@ |
||
| 55 | 55 | * @return DatatableView the view to work with |
| 56 | 56 | */ |
| 57 | 57 | public function view($view = null) { |
| 58 | - return new DatatableView($view, $this->versionEngine->getVersion()); |
|
| 58 | + return new DatatableView($view, $this->versionEngine->getVersion()); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -2,11 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace OpenSkill\Datatable\Queries\Parser; |
| 4 | 4 | |
| 5 | -use Illuminate\Http\JsonResponse; |
|
| 6 | 5 | use Illuminate\Http\Request; |
| 7 | 6 | use OpenSkill\Datatable\Columns\ColumnConfiguration; |
| 8 | 7 | use OpenSkill\Datatable\Queries\QueryConfiguration; |
| 9 | -use Symfony\Component\HttpFoundation\Response; |
|
| 10 | 8 | |
| 11 | 9 | /** |
| 12 | 10 | * Interface DTQueryParser |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * @param ResponseData $data The processed data. |
| 16 | 16 | * @param QueryConfiguration $queryConfiguration the query configuration for the current request. |
| 17 | 17 | * @param array $columnConfiguration the column configurations for the current data table. |
| 18 | - * @return Response the response that should be returned to the client. |
|
| 18 | + * @return JsonResponse the response that should be returned to the client. |
|
| 19 | 19 | */ |
| 20 | 20 | public function createResponse(ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfiguration) |
| 21 | 21 | { |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * DatatableView constructor, will take a view as a string if a custom one should be used. will also take the |
| 23 | 23 | * column configurations to provide out of the box headers for the view. |
| 24 | 24 | * If no columns are given the user must provide them before building the view. |
| 25 | - * @param array $columnConfiguration The columnConfiguration of the the server side if available |
|
| 25 | + * @param string|null $columnConfiguration The columnConfiguration of the the server side if available |
|
| 26 | 26 | * @param Version $version The version that supports the current request |
| 27 | 27 | * @param string $view the name of the view that should be rendered |
| 28 | 28 | */ |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Will render the table |
| 44 | 44 | */ |
| 45 | 45 | public function table() { |
| 46 | - if(empty($this->columnConfigurations)) { |
|
| 46 | + if (empty($this->columnConfigurations)) { |
|
| 47 | 47 | throw new \InvalidArgumentException("There are no columns defined"); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Will render the javascript for the table |
| 53 | 53 | */ |
| 54 | 54 | public function script() { |
| 55 | - if(empty($this->columnConfigurations)) { |
|
| 55 | + if (empty($this->columnConfigurations)) { |
|
| 56 | 56 | throw new \InvalidArgumentException("There are no columns defined"); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | $this->app->tag(['DT19Version', 'dt.default.version'], 'dt.query.versions'); |
| 32 | 32 | |
| 33 | - $this->app->singleton("datatable", function (Application $app) { |
|
| 33 | + $this->app->singleton("datatable", function(Application $app) { |
|
| 34 | 34 | return new Datatable( |
| 35 | 35 | $app->make('request'), |
| 36 | 36 | new VersionEngine($app->tagged('dt.query.versions')) |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $this->collection = $collection; |
| 56 | 56 | $this->totalInitialDataCount = $collection->count(); |
| 57 | 57 | // define search functions |
| 58 | - $this->globalSearchFunction = function ($data, $search) { |
|
| 58 | + $this->globalSearchFunction = function($data, $search) { |
|
| 59 | 59 | foreach ($data as $item) { |
| 60 | 60 | if (str_contains(mb_strtolower($item), mb_strtolower($search))) { |
| 61 | 61 | return true; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | // generate a custom search function for each column |
| 83 | 83 | foreach ($this->columnConfiguration as $col) { |
| 84 | 84 | if (!array_key_exists($col->getName(), $this->columnSearchFunction)) { |
| 85 | - $this->columnSearchFunction[$col->getName()] = function ($data, ColumnSearch $search) use ($col) { |
|
| 85 | + $this->columnSearchFunction[$col->getName()] = function($data, ColumnSearch $search) use ($col) { |
|
| 86 | 86 | if (str_contains(mb_strtolower($data[$col->getName()]), mb_strtolower($search->searchValue()))) { |
| 87 | 87 | return true; |
| 88 | 88 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $searchFunc = $this->globalSearchFunction; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $this->collection->transform(function ($data) use ($columnConfiguration, $searchFunc) { |
|
| 140 | + $this->collection->transform(function($data) use ($columnConfiguration, $searchFunc) { |
|
| 141 | 141 | $entry = []; |
| 142 | 142 | // for each column call the callback |
| 143 | 143 | foreach ($columnConfiguration as $i => $col) { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | return $entry; |
| 162 | 162 | }); |
| 163 | 163 | |
| 164 | - $this->collection = $this->collection->reject(function ($data) { |
|
| 164 | + $this->collection = $this->collection->reject(function($data) { |
|
| 165 | 165 | if (empty($data)) { |
| 166 | 166 | return true; |
| 167 | 167 | } else { |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | if ($this->queryConfiguration->hasOrderColumn()) { |
| 205 | 205 | $order = $this->queryConfiguration->orderColumns()[0]; |
| 206 | - $this->collection->sort(function ($first, $second) use ($order) { |
|
| 206 | + $this->collection->sort(function($first, $second) use ($order) { |
|
| 207 | 207 | return strnatcmp($first[$order->columnName()], $second[$order->columnName()]); |
| 208 | 208 | }); |
| 209 | - if(!$order->isAscending()) { |
|
| 209 | + if (!$order->isAscending()) { |
|
| 210 | 210 | $this->collection->reverse(); |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | { |
| 144 | 144 | if (is_null($this->callable) || !is_callable($this->callable)) { |
| 145 | 145 | $self = $this; |
| 146 | - $this->callable = function ($data) use (&$self) { |
|
| 146 | + $this->callable = function($data) use (&$self) { |
|
| 147 | 147 | $name = $self->name; |
| 148 | 148 | |
| 149 | 149 | if (is_array($data) && array_key_exists($name, $data)) { |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | if (!is_null($callable)) { |
| 97 | 97 | if (is_callable($callable)) { |
| 98 | 98 | $config->withCallable($callable); |
| 99 | - } elseif (is_string($callable)){ |
|
| 99 | + } elseif (is_string($callable)) { |
|
| 100 | 100 | $config->withCallable(function($data) use ($callable) { return $callable; }); |
| 101 | 101 | } |
| 102 | 102 | } |