abordage / nova-total-card
A Laravel Nova card that displays the total number of records of a specific model
Installs: 34 119
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: >=7.4
- laravel/nova: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^5.0 || ^6.0 || ^7.0 || ^8.0
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.6 || ^10.0
This package is auto-updated.
Last update: 2024-11-11 02:21:38 UTC
README
Nova Total Card
A Laravel Nova card that displays the total number of records for a model or the number of records matching a condition.
Requirements
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
- Nova 4
Installation
You can install the package via composer:
composer require abordage/nova-total-card
Usage
To add this card to the dashboard or resource add it to the cards
method like this:
namespace App\Nova\Dashboards; use Abordage\TotalCard\TotalCard; use Laravel\Nova\Dashboard; class Main extends Dashboard { public function cards(): array { $cards = [ /* simple */ new TotalCard(\App\Models\User::class), /* with custom title */ new TotalCard(\App\Models\User::class, 'All users'), /* with cache expiry time */ new TotalCard(\App\Models\User::class, 'All users', now()->addHour()), /* with condition */ new TotalCard(\App\Models\User::where('is_active', 1), 'Active users'), ]; } }
You can set the size of the card using the methods width
and height
:
public function cards(): array { $cards = [ (new TotalCard(\App\Models\User::class))->height('dynamic'), (new TotalCard(\App\Models\User::class))->height('dynamic')->width('2/3'), ]; }
Feedback
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
Credits
Thanks to
The original idea comes from the total-records, so many thanks to its author and contributors!
License
The MIT License (MIT). Please see License File for more information.