This Laravel Nova package is used for calculating the total of the columns that you wish to show.
php: ^8.1
laravel/nova: ^5.0
Install via composer:
composer require marshmallow/nova-totals-footer
To include specific fields in the table footer, invoke their respective calculate
methods. Within this method, specify the calculation logic to determine the desired value. By default, the available calculation methods include sum
, count
, avg
, min
and max
. Refer to the example below for further clarification.
Currency::make('Revenue', 'revenue')
->required()
/** 👇 This is where the magic happens */
->calculate(
method: 'sum', // sum, count, avg, min and max
title: 'Total',
prefix: '$',
postfix: '.00',
hideTitle: true, // true, false (default)
align: 'right', // left, right (default), center
titleAlign: 'right', // left, right (default), center
),
This sound weird, but sometimes we needed to hide the header of the footer. We didn't need this extra footer row. Is you need to hide this, you can call the method below.
use Marshmallow\NovaTotalsFooter\NovaTotalsFooter;
NovaTotalsFooter::hideHeader();
The MIT License (MIT). Please see License File for more information.
If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.
Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests.
At Marshmallow we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!
We hope you will enjoy this small contribution from us and would love to hear from you if you find it useful in your projects. Follow us on Twitter for more updates!