PHP code example of jamal / universal-search-filter
1. Go to this page and download the library: Download jamal/universal-search-filter 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/ */
jamal / universal-search-filter example snippets
use Illuminate\Database\Eloquent\Model;
use Jamal\UniversalSearchFilter\Traits\UniversalSearchable;
class User extends Model
{
use UniversalSearchable;
// Optional per-model config
protected array $universalSearch = [
'columns' => ['name', 'email', 'phone'],
'relations' => [
'posts' => ['title', 'body'],
],
'weights' => [
'name' => 3,
'email' => 2,
'posts' => 1, // weight applied to each related column
],
'fuzzy' => true,
'exclude_zero_relevancy' => true
];
}