Skip to content

Make Admin Dashboard compatible with immutable Carbon Dates#2307

Merged
alecritson merged 2 commits intolunarphp:1.xfrom
thettler:make-compatible-with-immutable-dates
Oct 14, 2025
Merged

Make Admin Dashboard compatible with immutable Carbon Dates#2307
alecritson merged 2 commits intolunarphp:1.xfrom
thettler:make-compatible-with-immutable-dates

Conversation

@thettler
Copy link
Contributor

@thettler thettler commented Oct 3, 2025

If you want to use ImmutableDates in your Application with this line:

Illuminate\Support\Facades\Date::use(CarbonImmutable::class);

The Dashboard Widgets break because the signature of the getOrderQuery methods on the Widgets is to strict.

The Error:

Lunar\Admin\Filament\Widgets\Dashboard\Orders\NewVsReturningCustomersChart::getOrderQuery():
Argument #1 ($from) must be of type ?DateTime, Carbon\CarbonImmutable given, called in
 Packages/lunar/packages/lunar/packages/admin/src/Filament/Widgets/Dashboard/Orders/NewVsReturningCustomersChart.php on line 47

This PR changes the signature to accept also CarbonDates which solves the Problem.

Old Signature:

protected function getOrderQuery(?\DateTime $from = null, ?\DateTime $to = null);

New Signature:

protected function getOrderQuery(\DateTime|CarbonInterface|null $from = null, \DateTime|CarbonInterface|null $to = null);

Warning

This is a breaking change for people who extended one or more widgets and have overwritten the getOrderQuery method. But the Impact is in a non critical part and the required work to upgrade is minimal.

@vercel
Copy link

vercel bot commented Oct 3, 2025

@thettler is attempting to deploy a commit to the NEON Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the Admin Dashboard widgets compatible with immutable Carbon dates by updating method signatures to accept both DateTime and CarbonInterface types. The change fixes a type error that occurs when using CarbonImmutable dates in Laravel applications.

  • Updated getOrderQuery method signatures across all dashboard order widgets to accept \DateTime|CarbonInterface|null parameters
  • Added necessary use Carbon\CarbonInterface; imports to all affected widget classes

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
OrdersSalesChart.php Updated getOrderQuery signature and added CarbonInterface import
OrderTotalsChart.php Updated getOrderQuery signature and added CarbonInterface import
OrderStatsOverview.php Updated getOrderQuery signature and added CarbonInterface import
NewVsReturningCustomersChart.php Updated getOrderQuery signature and added CarbonInterface import
AverageOrderValueChart.php Updated getOrderQuery signature and added CarbonInterface import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@alecritson alecritson merged commit 0d2a4c6 into lunarphp:1.x Oct 14, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants