Skip to content

Commit

Permalink
Merge pull request #3938 from sswm1975/ScopeSeparator
Browse files Browse the repository at this point in the history
Scope separator
  • Loading branch information
z-song committed Sep 27, 2019
2 parents 688f04b + 5ce4c3a commit 82dfd54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Grid/Filter.php
Expand Up @@ -422,6 +422,16 @@ public function scope($key, $label = '')
});
}

/**
* Add separator in filter scope.
*
* @return mixed
*/
public function scopeSeparator()
{
return $this->scope(Scope::SEPARATOR);
}

/**
* Get all filter scopes.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Grid/Filter/Scope.php
Expand Up @@ -9,6 +9,7 @@
class Scope implements Renderable
{
const QUERY_NAME = '_scope_';
const SEPARATOR = '_separator_';

/**
* @var string
Expand Down Expand Up @@ -66,6 +67,10 @@ public function condition()
*/
public function render()
{
if ($this->key == static::SEPARATOR) {
return '<li role="separator" class="divider"></li>';
}

$url = request()->fullUrlWithQuery([static::QUERY_NAME => $this->key]);

return "<li><a href=\"{$url}\">{$this->label}</a></li>";
Expand Down

0 comments on commit 82dfd54

Please sign in to comment.