abordage / nova-total-card
一个显示特定模型记录总数的 Laravel Nova 卡片
0.2.1
2024-03-23 18:04 UTC
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
README
Nova 总数卡片
一个 Laravel Nova 卡片,显示模型的记录总数或匹配条件的记录数。
需求
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
- Nova 4
安装
您可以通过 composer 安装此软件包
composer require abordage/nova-total-card
用法
要将此卡片添加到仪表板或资源,请将其添加到 cards
方法,如下所示
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'), ]; } }
您可以使用 width
和 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'), ]; }
反馈
如果您有任何反馈、评论或建议,请随时在此存储库中提交问题。
致谢
感谢
原始想法来自 total-records,因此非常感谢其作者和贡献者!
许可证
MIT 许可证(MIT)。请参阅许可证文件以获取更多信息。