PHP code example of beyondcode / nova-filterable-cards

1. Go to this page and download the library: Download beyondcode/nova-filterable-cards library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

beyondcode / nova-filterable-cards example snippets


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

use FilterableValue;


// in your filterable Nova metric card class:

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

// 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'
		],
	];
}


// in your filterable Nova metric card class:

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