{"id":22889609,"url":"https://github.com/dillingham/nova-list-card","last_synced_at":"2025-05-07T14:46:11.708Z","repository":{"id":37663231,"uuid":"183684673","full_name":"dillingham/nova-list-card","owner":"dillingham","description":"Add a variety of resource lists to Nova dashboards","archived":false,"fork":false,"pushed_at":"2023-06-06T18:28:26.000Z","size":38,"stargazers_count":42,"open_issues_count":3,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T18:16:48.394Z","etag":null,"topics":["laravel","laravel-nova"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dillingham.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-26T19:39:07.000Z","updated_at":"2024-10-12T04:21:51.000Z","dependencies_parsed_at":"2022-09-09T04:00:44.176Z","dependency_job_id":null,"html_url":"https://github.com/dillingham/nova-list-card","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-list-card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-list-card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-list-card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-list-card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dillingham","download_url":"https://codeload.github.com/dillingham/nova-list-card/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252898370,"owners_count":21821605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-nova"],"created_at":"2024-12-13T21:56:22.248Z","updated_at":"2025-05-07T14:46:11.689Z","avatar_url":"https://github.com/dillingham.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nova List Card\n\n[![Latest Version on Github](https://img.shields.io/github/release/dillingham/nova-list-card.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-list-card)\n[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-list-card.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-list-card) [![Twitter Follow](https://img.shields.io/twitter/follow/im_brian_d?color=%231da1f1\u0026label=Twitter\u0026logo=%231da1f1\u0026logoColor=%231da1f1\u0026style=flat-square)](https://twitter.com/im_brian_d)\n\nAdd a variety of lists to your dashboard\n\n![nova-list-card](https://user-images.githubusercontent.com/29180903/56833461-88905e80-683c-11e9-8a04-e3a7ce8dc582.png)\n\n### Install\n```bash\ncomposer require dillingham/nova-list-card\n```\n\n### Basic Usage\n\n```bash\nphp artisan nova:list-card RecentUsers\n```\n\n```php\n\u003c?php\n\nnamespace App\\Nova\\Metrics;\n\nuse App\\Nova\\User;\nuse NovaListCard\\ListCard;\n\nclass RecentUsers extends ListCard\n{\n    /**\n     * Setup the card options\n     */\n    public function __construct()\n    {\n        $this-\u003eresource(User::class)\n            -\u003eheading('Recent Users')\n            -\u003eorderBy('created_at', 'desc')\n            -\u003etimestamp()\n            -\u003eviewAll();\n    }\n```\n\n[View more examples](https://github.com/dillingham/nova-list-card#examples)\n\n### Possible Scenarios\n- Latest resource / oldest resource\n- Upcoming / past due resources\n- Top resource by relationship count\n- Top resource by relationship's column sum\n\n\n**Card Width**\n\nSet the card's width, default 1/3\n```php\n-\u003ewidth('3/5')\n```\n\n**Card Heading**\n\n```php\n-\u003eheading('Top Bloggers')\n```\n\n**Resource Subtitle**\n\nDisplay resource [subtitle](https://nova.laravel.com/docs/2.0/search/global-search.html#subtitles) beneath the title\n```php\n-\u003esubtitle(),\n```\nor display resource proporties beneath the title\n```php\n-\u003esubtitle('city'),\n```\n\n**Timestamps**\n\nAdds timestamp beneath resource title\n\nOptionally can add as a side value, see below.\n\nDefaults: created_at \u0026 moment.js format: MM/DD/YYYY:\n```php\n-\u003etimestamp(),\n-\u003etimestamp('due_at'),\n-\u003etimestamp('completed_at', 'MM/DD'),\n```\nRelative timestamps: `5 days ago` | `in 5 days`\n```php\n-\u003etimestamp('completed_at', 'relative'),\n```\n\n**Side Values**\n\nDisplay resource values on the right side\n```php\n-\u003evalue('city'),\n```\n\n**Aggregated Count**\n\nAdd counts of relationships:\n```php\n-\u003eresource(Category::class)\n-\u003ewithCount('posts')\n-\u003evalue('category_posts'),\n```\n\n**Aggregated Sum**\n\nAdd sum of relationship's column:\n```php\n-\u003eresource(User::class)\n-\u003ewithSum('orders', 'total')\n-\u003evalue('orders_sum'),\n```\n\n**Value formatting**\n\nYou can change the value output using [numeral.js](http://numeraljs.com/#format)\n\n```php\n-value('orders_sum') // 55200\n-value('orders_sum', '0.0a') // 55.2k\n-value('orders_sum', '($ 0.00 a)') // $55.2k\n```\nValue Timestamp: add third parameter for [moment.js formats](https://momentjs.com/docs/#/displaying/format/)\n```php\n-\u003evalue('created_at') // 2019-04-27 00:00:00\n-\u003evalue('created_at', 'MM/DD', 'timestamp') // 04/27\n-\u003evalue('created_at', 'relative', 'timestamp') // 5 days ago\n```\n\n**Limit**\n\nSet the number of items to display, default: 5:\n```php\n-\u003elimit(3)\n```\n\n**OrderBy**\n\nSet the order of the resources:\n```php\n-\u003eorderBy('scheduled_at', 'desc')\n```\n\n**Show View All Link**\n\nYou can link to the resource's index\n```php\n-\u003eviewAll()\n```\nOr to a lens attached to the resource\n```php\n-\u003eviewAllLens('most-popular-users')\n```\n\n**Footer Link**\n\nYou can link to a urL instead of using viewAll:\n```php\n-\u003efooterLink('Google', 'https://google.com')\n```\n\n**Scoped Resource**\n\nCheck the card's uri key within [IndexQuery](https://nova.laravel.com/docs/2.0/resources/authorization.html#index-filtering):\n\n```php\npublic static function indexQuery($request, $query)\n{\n    if($request-\u003einput('nova-list-card') == 'upcoming-tasks') {\n        $query-\u003ewhereNull('completed_at');\n    }\n\n    return $query;\n}\n```\n\n**CSS Classes**\n\nCustomize styles easily if you have your own theme.css\n```css\n.nova-list-card {}\n.nova-list-card-heading {}\n.nova-list-card-body {}\n.nova-list-card-item {}\n.nova-list-card-title {}\n.nova-list-card-subtitle {}\n.nova-list-card-timestamp {}\n.nova-list-card-value {}\n.nova-list-card-footer-link {}\n```\nAlso includes resource specific classes etc\n```css\n.nova-list-card.users.most-tasks\n```\nAlso can target specific rows\n```css\n.nova-list-card-item-1 {}\n.nova-list-card-item-2 {}\n.nova-list-card-item-3 {}\n```\nThe uri key is added to the card\n```css\n#upcoming-tasks {}\n```\nYou can also add classes manually\n```php\n-\u003eclasses('font-bold text-red some-custom-class')\n```\nYou can also add alternate row formatting\n```php\n-\u003ezebra()\n```\n\n# Examples\n\n![nova-list-card](https://user-images.githubusercontent.com/29180903/56833461-88905e80-683c-11e9-8a04-e3a7ce8dc582.png)\n\n```php\n-\u003eresource(Contact::class)\n-\u003eheading('Recent Contacts')\n-\u003esubtitle('email')\n-\u003etimestamp()\n-\u003elimit(3)\n-\u003eviewAll(),\n```\n```php\n-\u003eresource(Contact::class)\n-\u003eheading('Contacts: Most tasks', 'Tasks')\n-\u003eorderBy('tasks_count', 'desc')\n-\u003esubtitle('email')\n-\u003evalue('tasks_count')\n-\u003ewithCount('tasks')\n-\u003ezebra()\n-\u003eviewAll(),\n```\n```php\n-\u003eresource(Contact::class)\n-\u003eheading('Top Opportunities', 'Estimates')\n-\u003ewithSum('opportunities', 'estimate')\n-\u003evalue('opportunities_sum', '0.0a')\n-\u003eviewAllLens('top-opportunities')\n-\u003eorderBy('opportunities_sum', 'desc'),\n```\n\n### Methods\n\n| Method | Description |\n| - | - |\n| resource() | declare the resource |\n| heading() | add a title to card |\n| subtitle() | display subtitle value |\n| timestamp() | display \u0026 format timestamp |\n| value() | display right side value |\n| withCount() | aggregate count value |\n| withSum() | aggregate sum value |\n| orderBy() | set the resource order |\n| limit() | set number of resources |\n| viewAll() | enable view all link |\n| viewAllLens() | enable lens view all |\n| footerLink()| add a static footer link |\n| zebra() | add alternate row color |\n| id() | unique id for card's requests |\n| classes() | add css classes to card |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-list-card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdillingham%2Fnova-list-card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-list-card/lists"}