Skip to content

Commit

Permalink
wip: add options and resource url to the filter fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasan Deeb committed Jul 4, 2024
1 parent acb936b commit 9f12aa8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DTO/FilterField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Aldeebhasan\NaiveCrud\Traits\Makable;

/**@method static FilterField make(string $field, ?string $column = null, ?string $operator = '=', callable $callback = null, mixed $value = null) */
/**@method static FilterField make(string $field, ?string $column = null, ?string $operator = '=', callable $callback = null, mixed $value = null, array $options = []) */
final readonly class FilterField
{
use Makable;
Expand All @@ -22,7 +22,9 @@ public function __construct(
callable $callback = null,
public string $type = 'text',
public ?string $label = null,
public mixed $value = null
public mixed $value = null,
public array $options = [],
public string $resourceURL = '',
)
{
$this->callback = $callback;
Expand Down
2 changes: 2 additions & 0 deletions src/Logic/Resolvers/FilterResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ private function renderSingleField(FilterField $field): array
return [
'type' => $field->type,
'name' => $field->field,
'url' => $field->resourceURL,
'label' => $field->label ?? str($field->field)->title()->toString(),
'value' => (string) ($field->value ?? Arr::get($this->values, $field->field)),
'options' => $field->options,
];
}
}

0 comments on commit 9f12aa8

Please sign in to comment.