Skip to content

Commit

Permalink
nitpick
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Oct 4, 2024
1 parent 2b15e43 commit 55caaf3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 11 additions & 10 deletions src/Tags/Dictionary/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ class Dictionary extends Tags
*/
public function wildcard($tag)
{
$this->params['handle'] = $tag;

return $this->index();
return $this->loop($tag);
}

/**
* {{ dictionary handle="" }} ... {{ /dictionary }}.
*/
public function index()
{
if (! $handle = $this->params->pull('handle')) {
return $this->loop($this->params->pull('handle'));
}

private function loop($handle)
{
if (! $handle) {
return [];
}

Expand All @@ -44,18 +47,16 @@ public function index()
throw new DictionaryNotFoundException($handle);
}

$options = collect($dictionary->options($search))
->map(fn ($label, $value) => new DictionaryItem(array_merge(['label' => $label, 'value' => $value], $dictionary->get($value)->extra())))
$options = (new DataCollection($dictionary->options($search)))
->map(fn ($label, $value) => new DictionaryItem($dictionary->get($value)->toArray()))
->values();

$query = (new ItemQueryBuilder)->withItems(new DataCollection($options));
$query = (new ItemQueryBuilder)->withItems($options);

$this->queryConditions($query);
$this->queryOrderBys($query);
$this->queryScopes($query);

$options = $this->results($query);

return $this->output($options);
return $this->output($this->results($query));
}
}
3 changes: 1 addition & 2 deletions src/Tags/Dictionary/DictionaryItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class DictionaryItem implements Arrayable

public function __construct(public array $data)
{

}

public function get($key, $default = null)
Expand All @@ -22,6 +21,6 @@ public function get($key, $default = null)

public function toArray()
{
return array_merge($this->data, $this->supplements() ?? []);
return array_merge($this->data, $this->supplements ?? []);
}
}

0 comments on commit 55caaf3

Please sign in to comment.