Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
606 stars 64 forks source link

fix: error when using modified `dateAlias` value #33

Closed raymon-roos closed 1 year ago

raymon-roos commented 1 year ago

Hello,

When changing the dateAlias property like so:

  return $trend
            ->dateAlias('aggregation_date')
            ->dateColumn('date')
            ->between(
                start: now()->sub($this->filter, 1),
                end: now(),
            );

an errorException is thrown:

Undefined property: stdClass::$date

Looking through recent issues and pull requests, I came across these #13 and #28 . I noticed the mapValuesToDates() was missing a required change:

        $values = $values->map(fn ($value) => new TrendValue(
            date: $value->{$this->dateAlias},
            aggregate: $value->aggregate,
        ));

Thanks for considering.