Filters V2 to V3

Hi,

I migrated a project from V2 to V3. I have filters inside a model that doesn’t work anymore.

Individually, they work but when I have more than one, all the other ones are cleared.

image

The issue :

  1. I select few values in the “# membre” filter
  2. Then, I select few values in the “Groupe ID” filter
  3. Click on “Apply”
  4. The values that was selected previously in “# membre” filter are gone.

What I found :

For the “# member” scope, selected values are inside value and not scopeValue.

Any recommendations?

# ===================================
# Filter Scope Definitions
# ===================================

scopes:
    filter_member_id:
        label: larnet.osm::lang.backend.dealer.filter.filter_dealer
        modelScope: filterDealer
        options: getDealersOptions
        modelClass: Larnet\Osm\Models\Dealer
        dependsOn: 
            - filter_groupid
            - filter_city
            - filter_province
            - filter_bannerid
            - filter_pool
    filter_groupid:
        label: larnet.osm::lang.backend.dealer.filter.filter_groupid
        modelScope: filterGroupId
        options: getGroupIdsOptions
        modelClass: Larnet\Osm\Models\Dealer
        dependsOn:
            - filter_member_id
            - filter_city
            - filter_province
            - filter_bannerid
            - filter_pool

And in my model Dealer.php;

public function scopeFilterDealer($query, $scope) {
        return $query->whereIn('id', $scope->value);
    }

    public function scopeFilterGroupId($query, $scope) {
        $query->whereIn('group_id', $scope->value);
    }

Thank you.

Removed the dependsOn and it seems to be fine.

There is a line in the doc of the V3 that is not in V2 in the Filter Dependencies…

…the defining scope will reset…

Thanks for reporting back, and glad you got it sorted. The dependsOn wasn’t very well defined from before v2. The filter resets because it anticipates new or removed options, previously it resulted in an unhandled error.