Skip to content

Commit

Permalink
Merge pull request #928 from judgej/issue_775
Browse files Browse the repository at this point in the history
Issue 775
  • Loading branch information
David Mathews committed Oct 29, 2015
2 parents 92ca5c4 + 2739c18 commit cd5f1bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/Frozennode/Administrator/DataTable/Columns/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Frozennode\Administrator\Validator;
use Frozennode\Administrator\Config\ConfigInterface;
use Illuminate\Database\DatabaseManager as DB;
use Illuminate\Database\Eloquent\Model;

class Column {

Expand Down Expand Up @@ -240,16 +241,17 @@ public function getOption($key)
/**
* Takes a column output string and renders the column with it (replacing '(:value)' with the column's field value)
*
* @param string $value
* @param $value string $value
* @param \Illuminate\Database\Eloquent\Model $item
*
* @return string
*/
public function renderOutput($value)
public function renderOutput($value, $item = null)
{
$output = $this->getOption('output');

if (is_callable($output)) {
return $output($value);
return $output($value, $item);
}

return str_replace('(:value)', $value, $output);
Expand Down
4 changes: 2 additions & 2 deletions src/Frozennode/Administrator/DataTable/DataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function parseOnTableColumns($item, array &$outputRow)
{
$outputRow[$field] = array(
'raw' => $attributeValue,
'rendered' => $columns[$field]->renderOutput($attributeValue),
'rendered' => $columns[$field]->renderOutput($attributeValue, $item),
);
}
//otherwise it's likely the primary key column which wasn't included (though it's needed for identification purposes)
Expand Down Expand Up @@ -322,7 +322,7 @@ public function parseComputedColumns($item, array &$outputRow)
{
$outputRow[$name] = array(
'raw' => $item->{$name},
'rendered' => $columns[$name]->renderOutput($item->{$name}),
'rendered' => $columns[$name]->renderOutput($item->{$name}, $item),
);
}
}
Expand Down

0 comments on commit cd5f1bf

Please sign in to comment.