LaravelPackages.net
Acme Inc.
Toggle sidebar
radwanic/resource-listing

A Laravel Nova card.

14.498
3
1.0.4
About radwanic/resource-listing

radwanic/resource-listing is a Laravel package for a laravel nova card.. It currently has 3 GitHub stars and 14.498 downloads on Packagist (latest version 1.0.4). Install it with composer require radwanic/resource-listing. Discover more Laravel packages by radwanic or browse all Laravel packages to compare alternatives.

Last updated

This package allows you to list resources and order them based on a specific column

Installation

You can install the package in a Laravel app with Nova installed

composer require radwanic/resource-listing

Description

A Laravel Nova card that displays a list of resource items based on the criteria that you specify.

Basic Usage

Adding the snippet below to the dashboard cards function will display the most resent posts based on their created_at field

protected function cards()
{
	return [
		...
		(new ResourceListing())->resource(\App\Post::class)
	];
}

Screenshot basic

Available Methods

|Name| Description | Example | Default Value |--|--|--|--| | resource | sets the resource (must be set) | \App\Post::class | - | | cardTitle | sets card title, won't display a card title if not set | Recent Posts | empty string | | resourceTitleColumn | choose the resource model column which will be used in the listing | first_name - name - title | title | | resourceUri | sets the resource uri. only the title will be displayed if not set | /resoucres/posts/ | empty string | | limit | sets the maximum number of items that will be listed | 1 - 3 - 5 | 10 | | orderBy | sets the column that will be used to sort the list | updated_at - name - price - age | created_at | | order | sets the sorting direction | asc - desc | desc | | readableDate | sets the readable human date flag. this can be used with any date column | true - false | false |

Advanced Examples

  • Display recently updated posts, link each post to its resource url, and limit the results to 5
(new ResourceListing())  
 ->cardTitle('Recently Updated Posts')  
 ->resource(\App\TOYIT\Posts\Post::class)  
 ->resourceUrl('/resources/posts/') 
 ->orderBy('updated_at') 
 ->limit(5)

Screenshot recent posts

  • Get the most expensive products based on the price, and use name to display each item
(new ResourceListing())  
 ->cardTitle('Recently Updated Posts')  
 ->resource(\App\TOYIT\Posts\Post::class) 
 ->resourceUrl('/resources/posts/')   
 ->resourceTitleColumn('name')
 ->orderBy('price')
 ->limit(5)

Screenshot most expensive

  • Get the three oldest members based on the created_at column, transform the created_at to a readable human time diff, and set the order direction to asc
new ResourceListing())  
 ->cardTitle('Oldest Members')  
 ->resource(\App\TOYIT\Users\User::class)  
 ->resourceTitleColumn('name')  
 ->resourceUrl('/resources/users/')  
 ->readableDate(true)  
 ->orderBy('created_at')  
 ->order('asc'),

Screenshot oldest members

Security

If you discover any security related issues, please email [email protected]

Contributing

This is a basic package that covers few cases and has limited features. Any contributions are welcome and credited.

License

The MIT License (MIT). Please see License File for more information.

Star History Chart