Skip to content

Commit

Permalink
Fix datatable error when presenter is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrijsmihailovs committed Dec 21, 2017
1 parent c14673f commit 0f22042
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Traits/AdminUsersPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function paginate()
$model = $this->model;
$presenter = config('netcore.module-user.datatable.presenter');
$presenter = $presenter && class_exists($presenter) ? app($presenter) : null;
$rawColumns = [];

// Eager-load relations
if ($presenter && property_exists($presenter, 'with')) {
Expand All @@ -29,6 +30,9 @@ public function paginate()
// Presenter modifiers
if ($presenter) {
$this->modifyDatatableColumns($datatable, $presenter);

// Set columns that shouldn't be escaped.
$rawColumns = (array)property_exists($presenter, 'rawColumns') ? $presenter->rawColumns : [];
}

$actionsTd = config('netcore.module-user.datatable.actions_td');
Expand All @@ -38,9 +42,6 @@ public function paginate()
return view($actionsTd ?? 'user::users.tds.actions', compact('row', 'config'))->render();
});

// Set columns that shouldn't be escaped.
$rawColumns = (array)property_exists($presenter, 'rawColumns') ? $presenter->rawColumns : [];

$datatable->rawColumns(array_merge([
'action',
], $rawColumns));
Expand All @@ -67,4 +68,4 @@ private function modifyDatatableColumns(&$datatable, $presenter)
$datatable->editColumn($name, [$presenter, $method]);
}
}
}
}

0 comments on commit 0f22042

Please sign in to comment.