dillingham/nova-list-card
Composer 安装命令:
composer require dillingham/nova-list-card
包简介
List Nova Resources
README 文档
README
Add a variety of lists to your dashboard
Install
composer require dillingham/nova-list-card
Basic Usage
php artisan nova:list-card RecentUsers
<?php namespace App\Nova\Metrics; use App\Nova\User; use NovaListCard\ListCard; class RecentUsers extends ListCard { /** * Setup the card options */ public function __construct() { $this->resource(User::class) ->heading('Recent Users') ->orderBy('created_at', 'desc') ->timestamp() ->viewAll(); }
Possible Scenarios
- Latest resource / oldest resource
- Upcoming / past due resources
- Top resource by relationship count
- Top resource by relationship's column sum
Card Width
Set the card's width, default 1/3
->width('3/5')
Card Heading
->heading('Top Bloggers')
Resource Subtitle
Display resource subtitle beneath the title
->subtitle(),
or display resource proporties beneath the title
->subtitle('city'),
Timestamps
Adds timestamp beneath resource title
Optionally can add as a side value, see below.
Defaults: created_at & moment.js format: MM/DD/YYYY:
->timestamp(), ->timestamp('due_at'), ->timestamp('completed_at', 'MM/DD'),
Relative timestamps: 5 days ago | in 5 days
->timestamp('completed_at', 'relative'),
Side Values
Display resource values on the right side
->value('city'),
Aggregated Count
Add counts of relationships:
->resource(Category::class) ->withCount('posts') ->value('category_posts'),
Aggregated Sum
Add sum of relationship's column:
->resource(User::class) ->withSum('orders', 'total') ->value('orders_sum'),
Value formatting
You can change the value output using numeral.js
-value('orders_sum') // 55200 -value('orders_sum', '0.0a') // 55.2k -value('orders_sum', '($ 0.00 a)') // $55.2k
Value Timestamp: add third parameter for moment.js formats
->value('created_at') // 2019-04-27 00:00:00 ->value('created_at', 'MM/DD', 'timestamp') // 04/27 ->value('created_at', 'relative', 'timestamp') // 5 days ago
Limit
Set the number of items to display, default: 5:
->limit(3)
OrderBy
Set the order of the resources:
->orderBy('scheduled_at', 'desc')
Show View All Link
You can link to the resource's index
->viewAll()
Or to a lens attached to the resource
->viewAllLens('most-popular-users')
Footer Link
You can link to a urL instead of using viewAll:
->footerLink('Google', 'https://google.com')
Scoped Resource
Check the card's uri key within IndexQuery:
public static function indexQuery($request, $query) { if($request->input('nova-list-card') == 'upcoming-tasks') { $query->whereNull('completed_at'); } return $query; }
CSS Classes
Customize styles easily if you have your own theme.css
.nova-list-card {} .nova-list-card-heading {} .nova-list-card-body {} .nova-list-card-item {} .nova-list-card-title {} .nova-list-card-subtitle {} .nova-list-card-timestamp {} .nova-list-card-value {} .nova-list-card-footer-link {}
Also includes resource specific classes etc
.nova-list-card.users.most-tasks
Also can target specific rows
.nova-list-card-item-1 {} .nova-list-card-item-2 {} .nova-list-card-item-3 {}
The uri key is added to the card
#upcoming-tasks {}
You can also add classes manually
->classes('font-bold text-red some-custom-class')
You can also add alternate row formatting
->zebra()
Examples
->resource(Contact::class) ->heading('Recent Contacts') ->subtitle('email') ->timestamp() ->limit(3) ->viewAll(),
->resource(Contact::class) ->heading('Contacts: Most tasks', 'Tasks') ->orderBy('tasks_count', 'desc') ->subtitle('email') ->value('tasks_count') ->withCount('tasks') ->zebra() ->viewAll(),
->resource(Contact::class) ->heading('Top Opportunities', 'Estimates') ->withSum('opportunities', 'estimate') ->value('opportunities_sum', '0.0a') ->viewAllLens('top-opportunities') ->orderBy('opportunities_sum', 'desc'),
Methods
| Method | Description |
|---|---|
| resource() | declare the resource |
| heading() | add a title to card |
| subtitle() | display subtitle value |
| timestamp() | display & format timestamp |
| value() | display right side value |
| withCount() | aggregate count value |
| withSum() | aggregate sum value |
| orderBy() | set the resource order |
| limit() | set number of resources |
| viewAll() | enable view all link |
| viewAllLens() | enable lens view all |
| footerLink() | add a static footer link |
| zebra() | add alternate row color |
| id() | unique id for card's requests |
| classes() | add css classes to card |
dillingham/nova-list-card 适用场景与选型建议
dillingham/nova-list-card 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.21k 次下载、GitHub Stars 达 42, 最近一次更新时间为 2019 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dillingham/nova-list-card 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dillingham/nova-list-card 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dillingham/nova-list-card 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
A Laravel Nova Image field. you can paste or drag or chose an image
A Laravel Nova Mail testing tool.
统计信息
- 总下载量: 12.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 42
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-26
