protected function getArrayAndKeyName(string $fieldName, string $key): array
    {
        if (!in_array($key, ['filters', 'sorts'], true)) {
            throw new InvalidArgumentException('Key must be one of [filters, sorts]');
        }
        if (str_contains($fieldName, '.')) {
            $path         = explode('.', $fieldName);
            $name         = array_pop($path);
            $relationPath = implode('.', $path);
            $array        = array_get($this->relations, "$relationPath.$key", []);
        } else {
            $name  = $fieldName;
            $array = ($key === 'filters') ? $this->filters : $this->sorts;
        }
        return [$name, $array];
    }
protected function getArrayAndKeyName(string $fieldName, string $key): array
    {
        if (!in_array($key, ['filters', 'sorts'], true)) {
            throw new InvalidArgumentException('Key must be one of [filters, sorts]');
        }
        if (str_contains($fieldName, '.')) {
            $path         = explode('.', $fieldName);
            $name         = array_pop($path);
            $relationPath = implode('.', $path);
            $array        = array_get($this->relations, "$relationPath.$key", []);
        } else {
            $name  = $fieldName;
            $array = ($key === 'filters') ? $this->filters : $this->sorts;
        }
        return [$name, $array];
    }
protected function getArrayAndKeyName ( string $ fieldName , string $ key ) : array { if ( ! in_array ( $ key , [ 'filters' , 'sorts' ] , true ) ) { throw new InvalidArgumentException ( 'Key must be one of [filters, sorts]' ) ; } if ( str_contains ( $ fieldName , '.' ) ) { $ path = explode ( '.' , $ fieldName ) ; $ name = array_pop ( $ path ) ; $ relationPath = implode ( '.' , $ path ) ; $ array = array_get ( $ this -> relations , "$relationPath.$key" , [ ] ) ; } else { $ name = $ fieldName ; $ array = ( $ key === 'filters' ) ? $ this -> filters : $ this -> sorts ; } return [ $ name , $ array ] ; }
Helper function to figure out which array to use

@param string $fieldName Field name
@param string $key       filters or sorts

@throws InvalidArgumentException

@return array
Helper function to figure out which array to use