coroo / nova-chartjs

A Simple Dashboard Chart in Laravel Nova using Chart JS. Starting create your own dashboard with Chart JS Integration can save your time and help you maintain consistency across standard elements such as Bar, Stacked, Line, Area, Doughnut and Pie Chart.
https://coroo.github.io/nova-chartjs
MIT License
215 stars 72 forks source link

Support for soft deleted models #143

Open miloandco opened 2 years ago

miloandco commented 2 years ago

As far as I can see, it is not possible (when using Laravel Models) to filter on soft deletes.

For example, one month can have 10 new users created, but also have 3 users deleted. Then it would be useful to be able to somehow get a total of 10-3=7. Currently total would show up as 10, which can be both right or wrong, depending on your goal.

options([
  'withTrashed' => true, // Adds soft deleted rows to the result
  'onlyTrashed' => true, // Only soft deleted rows
  'calculateTotalAsNet' => true, // Subtracts soft deleted rows from total
])

Is this currently possible? Otherwise, it would make sense to add it to add some new options as displayed above. I can make a PR on it if anyone else needs it too.