PHP code example of thuyld_rabiloo / searchy

1. Go to this page and download the library: Download thuyld_rabiloo/searchy 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/ */

    

thuyld_rabiloo / searchy example snippets


return [
    'default' => 'fuzzy',
    'fieldName' => 'relevance',
    'drivers' => [
        'fuzzy' => [
            'class' => 'Rabiloo\Searchy\SearchDrivers\FuzzySearchDriver',
        ],
        'ufuzzy' => [
            'class' => 'Rabiloo\Searchy\SearchDrivers\FuzzySearchUnicodeDriver',
        ],
        'simple' => [
            'class' => 'Rabiloo\Searchy\SearchDrivers\SimpleSearchDriver',
        ],
        'levenshtein' => [
            'class' => 'Rabiloo\Searchy\SearchDrivers\LevenshteinSearchDriver',
        ],
    ],
];

use Rabiloo\Searchy\Traits\Searchable;
class SearchableModel extends Model 
{
    use Searchable;
    
    public function searchableColumns() 
    {
        return ['field_1', 'field_2'];
    }
}

$search = SearchableModel::search('keyword')->get();

$search = SearchableModel::fuzzySearch('keyword')->get();
$search = SearchableModel::uFuzzySearch('keyword')->get();

$search = SearchableModel::simpleSearch('keyword')->get();

$search = SearchableModel::levenshteinSearch('keyword')->get();
bash
php artisan vendor:publish --tag="searchy-config"