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

Add extendRecords to list #989

Merged
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
4 changes: 4 additions & 0 deletions app/admin/actions/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ public function makeList($alias)
$this->controller->listExtendQuery($query, $alias);
});

$widget->bindEvent('list.extendRecords', function ($records) use ($alias) {
return $this->controller->listExtendRecords($records, $alias);
});

$widget->bindEvent('list.overrideColumnValue', function ($record, $column, $value) use ($alias) {
return $this->controller->listOverrideColumnValue($record, $column, $alias);
});
Expand Down
9 changes: 9 additions & 0 deletions app/admin/traits/ListExtendable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public function listExtendQuery($query, $alias = null)
{
}

/**
* listExtendRecords controller override: Extend the records used for populating the list
* after the query is processed.
* @param Illuminate\Contracts\Pagination\LengthAwarePaginator|Illuminate\Database\Eloquent\Collection $records
*/
public function listExtendRecords($records, $alias = null)
{
}

/**
* Controller override: Extend the query used for populating the filter
* options before the default query is processed.
Expand Down
4 changes: 4 additions & 0 deletions app/admin/widgets/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ protected function getRecords()
$records = $model->get();
}

if ($event = $this->fireSystemEvent('admin.list.extendRecords', [&$records])) {
$records = $event;
}

return $this->records = $records;
}

Expand Down