Skip to content

Commit

Permalink
SearchControls: Provide base implementation for fetchFilterColumns()
Browse files Browse the repository at this point in the history
ipl-orm's column definitions are now "mature" enough for me to do this
  • Loading branch information
nilmerg committed Oct 13, 2022
1 parent 6193e3a commit faa6a75
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Compat/SearchControls.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ trait SearchControls
*
* @return array<string, string> Keys are column paths, values are labels
*/
abstract public function fetchFilterColumns(Query $query);
public function fetchFilterColumns(Query $query)
{
$columns = [];
foreach ($query->getResolver()->getColumnDefinitions($query->getModel()) as $name => $definition) {
$columns[$name] = $definition->getLabel();
}

return $columns;
}

/**
* Get whether {@see SearchControls::createSearchBar()} and {@see SearchControls::createSearchEditor()}
Expand Down

0 comments on commit faa6a75

Please sign in to comment.