Skip to content

Commit

Permalink
Fix #5000
Browse files Browse the repository at this point in the history
  • Loading branch information
z-song committed Sep 27, 2020
1 parent d576191 commit e3060ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Admin
*
* @var string
*/
const VERSION = '1.8.4';
const VERSION = '1.8.6';

/**
* @var Navbar
Expand Down
9 changes: 5 additions & 4 deletions src/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public function build()
$this->columnNames[] = $column->getName();
});

$this->buildRows($data);
$this->buildRows($data, $collection);

$this->builded = true;
}
Expand All @@ -581,13 +581,14 @@ public function build()
* Build the grid rows.
*
* @param array $data
* @param Collection $collection
*
* @return void
*/
protected function buildRows(array $data)
protected function buildRows(array $data, Collection $collection)
{
$this->rows = collect($data)->map(function ($model, $number) {
return new Row($number, $model, $this->keyName);
$this->rows = collect($data)->map(function ($model, $number) use ($collection) {
return new Row($number, $model, $collection->get($number)->getKey());
});

if ($this->rowsCallback) {
Expand Down
18 changes: 9 additions & 9 deletions src/Grid/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ class Row
/**
* @var string
*/
protected $keyName;
protected $key;

/**
* Constructor.
*
* @param $number
* @param $data
* Row constructor.
* @param mixed $number
* @param array $data
* @param mixed $key
*/
public function __construct($number, $data, $keyName)
public function __construct($number, $data, $key)
{
$this->data = $data;
$this->number = $number;
$this->keyName = $keyName;
$this->key = $key;

$this->attributes = [
'data-key' => $this->getKey(),
'data-key' => $key,
];
}

Expand All @@ -60,7 +60,7 @@ public function __construct($number, $data, $keyName)
*/
public function getKey()
{
return Arr::get($this->data, $this->keyName);
return $this->key;
}

/**
Expand Down

0 comments on commit e3060ea

Please sign in to comment.