Skip to content

Commit

Permalink
Merge pull request #3 from kirschbaum-development/dev
Browse files Browse the repository at this point in the history
Add the meta field
  • Loading branch information
dvanscott authored Feb 28, 2022
2 parents 754f132 + 77eee7f commit 56188e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `livewire-filters` will be documented in this file.

## 0.1 - 202X-XX-XX
## 0.2 - 2022-02-28

- initial release
- Added the `meta` field to `Filter` class

## 0.1 - 2022-02-28

- Initial release
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ If you would like to set the value of a filter, you can pass the value or an arr

When defining a filter, you should use the `default` method to set the initial value of the filter. This will store the initial value on the object as well to help with determining the status of active filters as well as resetting the filter to its original state. Calling the `default` method without any arguments will return the initial value that you specified when you defined the filter.

### `meta(array $values)`

If you would like to set additional information on the filter to be used in the view file, you can pass an array of values into the `meta` method. Calling the `meta` method without any arguments will return the current array of meta information.

## Events

### `livewire-filters-reset`
Expand Down
3 changes: 2 additions & 1 deletion src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public function __construct(
public string $key,
public ?array $options = [],
public mixed $value = '',
public mixed $initialValue = ''
public mixed $initialValue = '',
public array $meta = []
) {
}

Expand Down
3 changes: 3 additions & 0 deletions src/FilterComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ abstract class FilterComponent extends Component

public string $key = '';

public array $meta = [];

public array $options = [];

public mixed $value;

public function mount(Filter $filter): void
{
$this->key = $filter->key();
$this->meta = $filter->meta();
$this->options = $filter->options();
$this->value = $filter->value();

Expand Down

0 comments on commit 56188e9

Please sign in to comment.