Skip to content

Commit 266b6a9

Browse files
authored
Merge pull request yajra#2171 from lloricode/patch-1
Fix deprecated helper functions, then add support for Laravel 6.
2 parents 7dfa13c + eb7a007 commit 266b6a9

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
],
1616
"require": {
1717
"php": "^7.1.3",
18-
"illuminate/database": "5.8.*",
19-
"illuminate/filesystem": "5.8.*",
20-
"illuminate/http": "5.8.*",
21-
"illuminate/support": "5.8.*",
22-
"illuminate/view": "5.8.*"
18+
"illuminate/database": "5.8.*|^6.0",
19+
"illuminate/filesystem": "5.8.*|^6.0",
20+
"illuminate/http": "5.8.*|^6.0",
21+
"illuminate/support": "5.8.*|^6.0",
22+
"illuminate/view": "5.8.*|^6.0"
2323
},
2424
"require-dev": {
2525
"orchestra/testbench": "^3.8"

src/CollectionDataTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ protected function defaultOrdering()
261261

262262
$this->collection = $this->collection
263263
->map(function ($data) {
264-
return array_dot($data);
264+
return Arr::dot($data);
265265
})
266266
->sort($sorter)
267267
->map(function ($data) {
268268
foreach ($data as $key => $value) {
269269
unset($data[$key]);
270-
array_set($data, $key, $value);
270+
Arr::set($data, $key, $value);
271271
}
272272

273273
return $data;

src/DataTableAbstract.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Yajra\DataTables;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Support\Str;
67
use Psr\Log\LoggerInterface;
78
use Illuminate\Http\JsonResponse;
@@ -255,7 +256,7 @@ public function escapeColumns($columns = '*')
255256
*/
256257
public function makeHidden(array $attributes = [])
257258
{
258-
$this->columnDef['hidden'] = array_merge_recursive(array_get($this->columnDef, 'hidden', []), $attributes);
259+
$this->columnDef['hidden'] = array_merge_recursive(Arr::get($this->columnDef, 'hidden', []), $attributes);
259260

260261
return $this;
261262
}
@@ -547,7 +548,7 @@ protected function getColumnsDefinition()
547548
$config = $this->config->get('datatables.columns');
548549
$allowed = ['excess', 'escape', 'raw', 'blacklist', 'whitelist'];
549550

550-
return array_replace_recursive(array_only($config, $allowed), $this->columnDef);
551+
return array_replace_recursive(Arr::only($config, $allowed), $this->columnDef);
551552
}
552553

553554
/**

src/DataTablesServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Yajra\DataTables;
44

5+
use Illuminate\Support\Str;
56
use Yajra\DataTables\Utilities\Config;
67
use Illuminate\Support\ServiceProvider;
78
use Yajra\DataTables\Utilities\Request;
@@ -42,7 +43,7 @@ public function boot()
4243
{
4344
$engines = config('datatables.engines');
4445
foreach ($engines as $engine => $class) {
45-
$engine = camel_case($engine);
46+
$engine = Str::camel($engine);
4647

4748
if (! method_exists(DataTables::class, $engine) && ! DataTables::hasMacro($engine)) {
4849
DataTables::macro($engine, function () use ($class) {
@@ -77,6 +78,6 @@ protected function setupAssets()
7778
*/
7879
protected function isLumen()
7980
{
80-
return str_contains($this->app->version(), 'Lumen');
81+
return Str::contains($this->app->version(), 'Lumen');
8182
}
8283
}

src/Processors/DataProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected function escapeColumns(array $output)
243243
} elseif (is_array($this->escapeColumns)) {
244244
$columns = array_diff($this->escapeColumns, $this->rawColumns);
245245
foreach ($columns as $key) {
246-
array_set($row, $key, e(array_get($row, $key)));
246+
Arr::set($row, $key, e(Arr::get($row, $key)));
247247
}
248248
}
249249

@@ -259,15 +259,15 @@ protected function escapeColumns(array $output)
259259
*/
260260
protected function escapeRow(array $row)
261261
{
262-
$arrayDot = array_filter(array_dot($row));
262+
$arrayDot = array_filter(Arr::dot($row));
263263
foreach ($arrayDot as $key => $value) {
264264
if (! in_array($key, $this->rawColumns)) {
265265
$arrayDot[$key] = e($value);
266266
}
267267
}
268268

269269
foreach ($arrayDot as $key => $value) {
270-
array_set($row, $key, $value);
270+
Arr::set($row, $key, $value);
271271
}
272272

273273
return $row;

src/Utilities/Helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Yajra\DataTables\Utilities;
44

55
use DateTime;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Str;
78
use Illuminate\Contracts\Support\Arrayable;
89

@@ -156,7 +157,7 @@ public static function getOrMethod($method)
156157
*/
157158
public static function convertToArray($row, $filters = [])
158159
{
159-
$row = method_exists($row, 'makeHidden') ? $row->makeHidden(array_get($filters, 'hidden', [])) : $row;
160+
$row = method_exists($row, 'makeHidden') ? $row->makeHidden(Arr::get($filters, 'hidden', [])) : $row;
160161
$data = $row instanceof Arrayable ? $row->toArray() : (array) $row;
161162

162163
foreach ($data as &$value) {

0 commit comments

Comments
 (0)