Skip to content

laravel 8 support #126

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
}
],
"require": {
"illuminate/view": "^5.5|^6",
"illuminate/support": "^5.5|^6",
"illuminate/console": "^5.5|^6",
"illuminate/contracts": "^5.5|^6",
"illuminate/http": "^5.5|^6",
"illuminate/database": "^5.5|^6",
"illuminate/pagination": "^5.5|^6"
"illuminate/view": "^5.5|^6|^8",
"illuminate/support": "^5.5|^6|^8",
"illuminate/console": "^5.5|^6|^8",
"illuminate/contracts": "^5.5|^6|^8",
"illuminate/http": "^5.5|^6|^8",
"illuminate/database": "^5.5|^6|^8",
"illuminate/pagination": "^5.5|^6|^8"
},
"suggest": {
"maatwebsite/excel": "For exporting grid data as excel (~3.0)",
Expand Down
3 changes: 2 additions & 1 deletion src/Buttons/GenericButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Leantony\Grid\Buttons;

use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
use InvalidArgumentException;

class GenericButton implements Htmlable
Expand Down Expand Up @@ -352,7 +353,7 @@ public function render(...$args)

// collapse the array of args into a single 1d array, so that the values passed can be
// accessed as key value pair
$args = array_collapse($args);
$args = Arr::collapse($args);

return view($this->getButtonView(), $this->compactData($args))->render();
}
Expand Down
6 changes: 4 additions & 2 deletions src/Buttons/RendersButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Leantony\Grid\Buttons;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;

trait RendersButtons
Expand Down Expand Up @@ -251,7 +253,7 @@ public function hasButtons(string $section = 'toolbar')
return false;
}
// no buttons on section
return count(array_get($this->buttons, $section, [])) === 0 ? false : true;
return count(Arr::get($this->buttons, $section, [])) === 0 ? false : true;
}

/**
Expand Down Expand Up @@ -303,7 +305,7 @@ protected function makeCustomButton(array $properties, $position = null): Generi
*/
protected function makeButtonKey(string $name)
{
return str_slug($name);
return Str::slug($name);
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/Commands/GenerateGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Leantony\Grid\HasGridConfigurations;

Expand Down Expand Up @@ -104,10 +105,10 @@ public function handle()
die(-1);
}

list($model, $rows) = $this->generateRows($suppliedModel);
[$model, $rows] = $this->generateRows($suppliedModel);

// binding
list($namespace, $replaced, $filename) = $this->dumpBinding($model);
[$namespace, $replaced, $filename] = $this->dumpBinding($model);

// class
$this->dumpClass($model, $rows, $stub);
Expand Down Expand Up @@ -263,7 +264,7 @@ protected function dumpBinding($model): array
{
$stub = __DIR__ . '/../Stubs/GridInterface.txt';

list($namespace, $interfaceName, $replaced) = $this->makeReplacementsForBinding($model,
[$namespace, $interfaceName, $replaced] = $this->makeReplacementsForBinding($model,
$this->generateDynamicNamespace(), $stub);

$this->binding = $interfaceName;
Expand Down Expand Up @@ -396,7 +397,7 @@ protected function makeDirectory($path)
*/
protected function dumpClass($model, $rows, $stub)
{
list($namespace, $tableName, $replaced) = $this->makeReplacements($model, $rows, $stub);
[$namespace, $tableName, $replaced] = $this->makeReplacements($model, $rows, $stub);

$filename = $this->makeFileName($tableName . 'Grid');

Expand Down Expand Up @@ -466,7 +467,7 @@ protected function replaceRows($rows, $stub)
*/
protected function replaceOtherContent(array $replacements, &$stub)
{
$replaced = str_replace(array_values(array_except($this->searches, 'rows')), [
$replaced = str_replace(array_values(Arr::except($this->searches, 'rows')), [
$replacements['namespace'],
$replacements['modelName'],
$replacements['tableName'],
Expand Down
3 changes: 2 additions & 1 deletion src/Events/UserActionRequested.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Leantony\Grid\Events;

use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Leantony\Grid\Grid;
use Leantony\Grid\GridInterface;

Expand Down Expand Up @@ -51,6 +52,6 @@ public function __construct(GridInterface $grid, Request $request, $builder, $va
$this->request = $request;
$this->builder = $builder;
$this->validTableColumns = $validTableColumns;
$this->args = array_collapse($args);
$this->args = Arr::collapse($args);
}
}
5 changes: 3 additions & 2 deletions src/Filters/GenericFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Leantony\Grid\Filters;

use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use InvalidArgumentException;

Expand Down Expand Up @@ -159,11 +160,11 @@ public function render()
// all filters apart from dropdowns are rendered as text elements.
// css classes or js libraries can be used to change this
return view('leantony::grid.filters.text', $this->compactData(
array_collapse(func_get_args())
Arr::collapse(func_get_args())
))->render();
case 'select':
return view('leantony::grid.filters.dropdown', $this->compactData(
array_collapse(func_get_args())
Arr::collapse(func_get_args())
))->render();
default:
throw new \Exception("Unknown filter type.");
Expand Down