All Projects → beyondcode → nova-filterable-cards

beyondcode / nova-filterable-cards

Licence: MIT License
Add custom filters to your Nova metric cards

Programming Languages

Vue
7211 projects
PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to nova-filterable-cards

nova-qrcode-field
A Laravel Nova field to generate QR Code
Stars: ✭ 28 (-50.88%)
Mutual labels:  nova
blueprint-nova-addon
A Blueprint addon which generates Nova resources
Stars: ✭ 61 (+7.02%)
Mutual labels:  nova
nova-rtl-theme
RTL layout for Laravel Nova.
Stars: ✭ 38 (-33.33%)
Mutual labels:  nova
nova-opening-hours-field
Laravel Nova custom field for https://github.com/spatie/opening-hours
Stars: ✭ 33 (-42.11%)
Mutual labels:  nova
nova-sluggable
Slug field for Laravel Nova
Stars: ✭ 40 (-29.82%)
Mutual labels:  nova
laravel-nova-order-nestedset-field
Laravel Nova field that make your resources orderable
Stars: ✭ 21 (-63.16%)
Mutual labels:  nova
nova-unlayer-field
🦜 Drag’n’drop email builder for Laravel Nova that uses Adds a Laravel Nova field for Unlayer service under the hood.
Stars: ✭ 27 (-52.63%)
Mutual labels:  nova
COA
Openstack Foundation Openstack Certified Administrator exam Preparation
Stars: ✭ 41 (-28.07%)
Mutual labels:  nova
nova-tabs
Another Laravel Nova Tabs Package
Stars: ✭ 60 (+5.26%)
Mutual labels:  nova
nova-horizon-stats
Nova cards for Laravel applications that use Laravel Horizon
Stars: ✭ 31 (-45.61%)
Mutual labels:  nova
nova-froala-editor
Froala editor input for laravel nova
Stars: ✭ 18 (-68.42%)
Mutual labels:  nova
nova-system-resources
Display the system usage in Laravel-Nova
Stars: ✭ 30 (-47.37%)
Mutual labels:  nova
laravel-nova-nested-form
This package allows you to include your nested relationships' forms into a parent form.
Stars: ✭ 225 (+294.74%)
Mutual labels:  nova
nova-horizon
Horizon statistics in Nova
Stars: ✭ 70 (+22.81%)
Mutual labels:  nova
nova-url-field
A URL input and link field for Laravel Nova
Stars: ✭ 96 (+68.42%)
Mutual labels:  nova
custom-relationship-field
Emulate HasMany relationship without having a real relationship set between resources
Stars: ✭ 18 (-68.42%)
Mutual labels:  nova
nova-mailman
Conveniently route all emails to a local mailbox.
Stars: ✭ 47 (-17.54%)
Mutual labels:  nova
nova-inspire
The best way to connect with your customers is by reaching out and inspiring them. ~ Me
Stars: ✭ 14 (-75.44%)
Mutual labels:  nova
Nova-Menu-Builder
A Menu Builder for Laravel Nova
Stars: ✭ 63 (+10.53%)
Mutual labels:  nova
nova-custom-dashboard-card
A Laravel Nova dashboard card that allows you to build custom dashboards.
Stars: ✭ 84 (+47.37%)
Mutual labels:  nova

Nova Filterable Metric Cards

Latest Version on Packagist Total Downloads Build Status

Add custom filters to your Laravel Nova metrics.

screenshot screenshot

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require beyondcode/nova-filterable-cards

Usage

To add the filter ability to your Laravel Nova metric cards, you need to add one of the Filterable traits to your metrics.

Depending on your metric type, these are the available traits:

  • FilterableValue
  • FilterableTrend
  • FilterablePartition

For example, within your custom Nova value metric card:

// in your Nova value metric card class:
import Beyondcode\FilterableCard\FilterableValue;

use FilterableValue;

Defining Filters

The available filters for your cards can be defined, by adding a new property called $filters to your metrics. This must be an array and contains the names of the available filters, as well as the properties for this specific filter.

Example:

// in your filterable Nova metric card class:

protected $filters = [
	'Firstname' => [
		'type' => 'text'
	],
	'Status' => [
		'type' => 'select',
		'options' => [
			'all' => 'All',
			'active' => 'Active',
			'inactive' => 'Inactive'
		],
	]
];

Defining Filters Using Define Methods

Sometimes you might want to set the available filter options by using a database call, or load them from the configuration. To enable this, you can also define the filter options using a method with the following naming convention: defineStudlyCaseFilterName.

So for example, if you want to add and define a custom filter called User Status, you can do it like this:

// in your filterable Nova metric card class:

protected $filters = [
	'Firstname' => [
		'type' => 'text'
	],
	'User Status'
];

public function defineUserStatus()
{
	return [
		'type' => 'select',
		'options' => [
			'all' => 'All',
			'active' => 'Active',
			'inactive' => 'Inactive'
		],
	];
}

Available Filter Types

The available filter types are:

  • select
  • checkbox
  • text
  • email
  • url
  • number

And all other types that can be applied to HTML <input> tags.

Apply The Filter Logic

To define in which way you want to filter your custom metric query, once a user filters it using the modal, you need to define custom filter methods. The naming convention is similar to defining custom filter options. It's filterStudlyCaseFilterName.

This method receives a query builder object and the value of the filter input. You can add your own queries to the builder class and modify as you need. Just make sure that you return the query object.

Example:

// in your filterable Nova metric card class:

public function filterUserStatus($query, $status)
{
	return $query->where('status', $status);
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].