> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eloquentfiltering.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Whats New v2

## Added

### FilterType Enum

All core filters provided by this package can be used via string or via new `FilterType` enum.

```php theme={null}
Filter::field('name', ['$like']);
Filter::field('name', [FilterType::LIKE]);
```

### Required Filters

Filters can be marked as required.

```php theme={null}
Filter::field('name', [FilterType::LIKE])->required();
```

<Tip>
  [Required Filters Documentation](/v2/digging-deeper/required-filters)
</Tip>

### Pivot Filters

Pivot filter support for `BelongsToMany` and `MorphToMany` relationships.

```php theme={null}
Filter::field('tagged_by', [FilterType::EQUAL])->pivot(Post::class);
```

<Tip>
  [Pivot Filters Documentation](/v2/digging-deeper/pivot-filters)
</Tip>

### Morph Filters

```php theme={null}
FilterType::HAS_MORPH
FilterType::DOESNT_HAS_MORPH
```

```php theme={null}
Filter::morphRelation(
    'subscribable',
    [FilterType::HAS_MORPH],
)->includeRelationFields([
    FoodDeliveryService::class,
    Saas::class,
])
```

<Tip>
  [Morph Filters Documentation](/v2/basics/in-detail#morph-relation)
</Tip>

### Validation Rules

Validation rules, messages, and attributes can be defined on a per `FilterType` basis.

```php theme={null}
Filter::field('status', [
    FilterType::IN->withValidation([
        'value.*' => [Rule::enum(OrderStatus::class)]
    ])
]),
```

<Tip>
  [Validation Rules Documentation](/v2/digging-deeper/validation-rules)
</Tip>

### Filter Modifiers

`$like:start` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/like#modifiers)

`$like:end` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/like#modifiers)

`$notLike:start` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/not-like#modifiers)

`$notLike:end` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/not-like#modifiers)

`$in:null` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/in#modifiers)

`$notIn:null` [<Icon icon="link" iconType="solid" />](/v2/available-filters/field-filters/not-in#modifiers)

### Exceptions

New exceptions for new features.

```php theme={null}
class InvalidFiltersPayloadException extends InvalidArgumentException
// When filters are passed to ::filter() that are not list arrays.

class InvalidModelFqcnException extends InvalidArgumentException
// When an invalid model string is passed to `Filter::morphType()` or `Filter::morphRelation()->includeRelationFields()`.

class UnsupportedModifierException extends InvalidArgumentException
// When an invalid modifier is passed to ->withModifiers().

class RequiredFilterException extends ValidationException
// When required filter(s) were not applied.
```

## Changed

### Qualifying Columns

By default, columns are now qualified with database table when using `Filter::field()` with any of the core filters provided by this package.

### Custom Filters Structure

Custom filters no longer should extend abstract classes.

<Tip>
  See [custom filters](/v2/digging-deeper/custom-filters) for how custom filter classes should now be structured.
</Tip>

## Removed

### Filters

Some dedicated filter classes were removed in favour of new **modifiers** feature.

* `$like:start`.
* `$like:end`.
* `$notLike:start`.
* `$notLike:end`.

`allowedFilters()` definitions should be updated.

```php theme={null}
public function allowedFilters(): AllowedFilterList
{
    return Filter::only(
        // old
        // Filter::field('name', ['$notLike:end']),
        // new (start & end modifiers enabled)
        Filter::field('name', [FilterType::NOT_LIKE]),
        // new (just end modifier enabled)
        Filter::field('name', [FilterType::NOT_LIKE->withModifiers('end')]),
    );
}
```

### Filter::all()

`Filter::all()` has been removed due to not being able to support pivot filters feature.
`Target::relationAlias()` has been removed due to `Filter::all()` being removed.

### Types::except()

Removed due to un-needed complexity.

### Config

`default_allowed_filter_list` has been removed from the config file due to `Filter::all()` being removed.

All `Filterable` models default to no filters allowed.
