PHP code example of mr-luke / searcher

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

    

mr-luke / searcher example snippets


/**
 * Determines rules for Searcher.
 *
 * @return array
 */
public static function getSearchableConfig() : array
{
	return [
    	'filter' => ['first' => 'firstName'],
        'query' => ['first', 'last'],
        'sort => ['age' => 'age'],
    ];
}

/**
 * Searcher configuration.
 *
 * @var array
 */
protected static $searchableConfig = [];

$collection = Searcher::setModel(User::class)->get();

setModel(string Model::class)

setModel(string Model::class, Builder $builder)

setModel(array $searchableConfig, Builder $builder)
bash
php artisan vendor:publish