PHP code example of jakeboyles / laravel-searchy

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

    

jakeboyles / laravel-searchy example snippets


TomLingham\Searchy\SearchyServiceProvider::class

'Searchy' => TomLingham\Searchy\Facades\Searchy::class

$users = Searchy::users('name', 'email')->query('John Smith')->get();

$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')->get();

$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')
    ->getQuery()->having('relevance', '>', 20)->get();

$users = Searchy::users('name', 'email', 'username')->query('John Smith')->get();

$users = Searchy::users('first_name::last_name')->query('John Smith')->get();

$users = Searchy::users('first_name::last_name')->query('John Smith')->select('first_name')->get();

// Or you can swap those around...
$users = Searchy::users('first_name::last_name')->select('first_name')->query('John Smith')->get();

Searchy::driver('fuzzy')->users('name')->query('Batman')->get();

Searchy::trashed()->users('name')->query('Batman')->get();

protected $matchers = [
	'TomLingham\Searchy\Matchers\ExactMatcher'                 => 100,
	'TomLingham\Searchy\Matchers\StartOfStringMatcher'         => 50,
	'TomLingham\Searchy\Matchers\InStringMatcher'              => 30,
];

protected $matchers = [
	'TomLingham\Searchy\Matchers\ExactMatcher'                 => 100,
	'TomLingham\Searchy\Matchers\StartOfStringMatcher'         => 50,
	'TomLingham\Searchy\Matchers\AcronymMatcher'               => 42,
	'TomLingham\Searchy\Matchers\ConsecutiveCharactersMatcher' => 40,
	'TomLingham\Searchy\Matchers\StartOfWordsMatcher'          => 35,
	'TomLingham\Searchy\Matchers\StudlyCaseMatcher'            => 32,
	'TomLingham\Searchy\Matchers\InStringMatcher'              => 30,
	'TomLingham\Searchy\Matchers\TimesInStringMatcher'         => 8,
];

protected $matchers = [
	'TomLingham\Searchy\Matchers\LevenshteinMatcher' => 100
];