Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0] Fix deprecated helper functions, then add support for Laravel 6. #2171

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
],
"require": {
"php": "^7.1.3",
"illuminate/database": "5.8.*",
"illuminate/filesystem": "5.8.*",
"illuminate/http": "5.8.*",
"illuminate/support": "5.8.*",
"illuminate/view": "5.8.*"
"illuminate/database": "5.8.*|^6.0",
"illuminate/filesystem": "5.8.*|^6.0",
"illuminate/http": "5.8.*|^6.0",
"illuminate/support": "5.8.*|^6.0",
"illuminate/view": "5.8.*|^6.0"
},
"require-dev": {
"orchestra/testbench": "^3.8"
Expand Down
4 changes: 2 additions & 2 deletions src/CollectionDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ protected function defaultOrdering()

$this->collection = $this->collection
->map(function ($data) {
return array_dot($data);
return Arr::dot($data);
})
->sort($sorter)
->map(function ($data) {
foreach ($data as $key => $value) {
unset($data[$key]);
array_set($data, $key, $value);
Arr::set($data, $key, $value);
}

return $data;
Expand Down
5 changes: 3 additions & 2 deletions src/DataTableAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Yajra\DataTables;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Psr\Log\LoggerInterface;
use Illuminate\Http\JsonResponse;
Expand Down Expand Up @@ -255,7 +256,7 @@ public function escapeColumns($columns = '*')
*/
public function makeHidden(array $attributes = [])
{
$this->columnDef['hidden'] = array_merge_recursive(array_get($this->columnDef, 'hidden', []), $attributes);
$this->columnDef['hidden'] = array_merge_recursive(Arr::get($this->columnDef, 'hidden', []), $attributes);

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

return array_replace_recursive(array_only($config, $allowed), $this->columnDef);
return array_replace_recursive(Arr::only($config, $allowed), $this->columnDef);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/DataTablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Yajra\DataTables;

use Illuminate\Support\Str;
use Yajra\DataTables\Utilities\Config;
use Illuminate\Support\ServiceProvider;
use Yajra\DataTables\Utilities\Request;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function boot()
{
$engines = config('datatables.engines');
foreach ($engines as $engine => $class) {
$engine = camel_case($engine);
$engine = Str::camel($engine);

if (! method_exists(DataTables::class, $engine) && ! DataTables::hasMacro($engine)) {
DataTables::macro($engine, function () use ($class) {
Expand Down Expand Up @@ -77,6 +78,6 @@ protected function setupAssets()
*/
protected function isLumen()
{
return str_contains($this->app->version(), 'Lumen');
return Str::contains($this->app->version(), 'Lumen');
}
}
6 changes: 3 additions & 3 deletions src/Processors/DataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function escapeColumns(array $output)
} elseif (is_array($this->escapeColumns)) {
$columns = array_diff($this->escapeColumns, $this->rawColumns);
foreach ($columns as $key) {
array_set($row, $key, e(array_get($row, $key)));
Arr::set($row, $key, e(Arr::get($row, $key)));
}
}

Expand All @@ -259,15 +259,15 @@ protected function escapeColumns(array $output)
*/
protected function escapeRow(array $row)
{
$arrayDot = array_filter(array_dot($row));
$arrayDot = array_filter(Arr::dot($row));
foreach ($arrayDot as $key => $value) {
if (! in_array($key, $this->rawColumns)) {
$arrayDot[$key] = e($value);
}
}

foreach ($arrayDot as $key => $value) {
array_set($row, $key, $value);
Arr::set($row, $key, $value);
}

return $row;
Expand Down
3 changes: 2 additions & 1 deletion src/Utilities/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Yajra\DataTables\Utilities;

use DateTime;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Arrayable;

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

foreach ($data as &$value) {
Expand Down