protected function resolveNestedRelations($data):array
    {
        if (is_null($data)) {
            return [];
        }

        $data = $data instanceof Model ? [$data] : $data;

        return collect($data)->flatMap(function ($model) {
            $relations = collect($model->getRelations());

            return $relations->keys()->merge($relations->flatMap(function ($relation, $key) {
                return collect($this->resolveNestedRelations($relation))->map(function ($nestedRelation) use ($key) {
                    return $key . '.' . $nestedRelation;
                });
            }));
        })->unique()->toArray();
    }