Package Data | |
---|---|
Maintainer Username: | akki-io |
Maintainer Contact: | hello@akki.io (Akki Khare) |
Package Create Date: | 2020-08-29 |
Package Last Update: | 2024-04-25 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:04:05 |
Package Statistics | |
---|---|
Total Downloads: | 452,133 |
Monthly Downloads: | 8,727 |
Daily Downloads: | 512 |
Total Stars: | 23 |
Total Watchers: | 1 |
Total Forks: | 7 |
Total Open Issues: | 1 |
MySQL -
SQLite -
pgSQL -
This package provides a trait that extends the search behaviour of laravel nova resource.
You can install the package via composer:
composer require akki-io/laravel-nova-search
Next, add AkkiIo\LaravelNovaSearch\LaravelNovaSearchable
trait to your base resource App\Nova\Resource
class.
use AkkiIo\LaravelNovaSearch\LaravelNovaSearchable;
abstract class Resource extends NovaResource
{
use LaravelNovaSearchable;
// ...
}
This package DOES NOT have fuzzy matching capabilities. If you are looking for robust fuzzy matching capabilities provided by "real" search engines, you should look into Laravel Scout.
This package adds the following types of search to your laravel nova resource.
To define which resource fields are searchable, you may assign a two-dimensional array of database columns in the public static $searchConcatenation
property of your resource class.
Each array in the array are names of columns that are concatenated using whitespace.
/**
* The columns that should be concatenated and searched.
*
* @var array
*/
public static $searchConcatenation = [
['first_name', 'last_name'],
['first_name', 'company'],
];
To define which resource fields are searchable, you may assign an array of database columns in the public static $searchMatchingAny
property of your resource class.
Every word in your input is searched for across all these columns.
/**
* The columns that should be searched for any matching entry.
*
* @var array
*/
public static $searchMatchingAny = [
'first_name',
'last_name',
'email',
];
To define which resource fields are searchable, you may assign an array of database columns in the public static $searchRelations
property of your resource class.
These database columns are from the related table that is used for searching.
This array has a relationship name as a key, and an array of columns to search for as a value.
/**
* The relationship columns that should be searched.
*
* @var array
*/
public static $searchRelations = [
'posts' => ['title', 'sub_title'],
];
You may search nested relationships using dot notation.
/**
* The relationship columns that should be searched.
*
* @var array
*/
public static $searchRelations = [
'user.location' => ['state_abbr', 'country_abbr],
];
To define which resource fields are searchable, you may assign a two-dimensional array of database columns in the public static $searchRelationsConcatenation
property of your resource class.
Each array in the array are names of columns that are concatenated using whitespace.
/**
* The relationship columns that should to be concatenated and searched.
*
* @var array
*/
public static $searchRelationsConcatenation = [
'user' => [
['first_name', 'last_name'],
['email']
],
];
To define which resource fields are searchable, you may assign an array of database columns in the public static $searchRelationsMatchingAny
property of your resource class.
Every word in your input is searched for across all these columns.
/**
* The relationship columns that should be searched for any matching entry.
*
* @var array
*/
public static $searchRelationsMatchingAny = [
'user' => ['first_name', 'last_name'],
];
composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email hello@akki.io instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.