PHP code example of websecret / laravel-search

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

    

websecret / laravel-search example snippets


'providers' => [
	// ...
	Websecret\LaravelSearchable\SearchableServiceProvider::class,
];

use Websecret\LaravelSearchable\SearchableTrait;
use Websecret\LaravelSearchable\SearchableInterface;

class Article extends Model implements SearchableInterface
{
	use SearchableTrait;

	protected $searchable = [
        //'index' => 'domain_name',
        //'type' => 'articles',
        'fields' => [
            'title' => [
                'weight' => 3,
            ],
            'content',
            'category.title' => [
                'title' => 'category',
                'weight' => 1,
            ],
        ],
        //"fuzziness" => "AUTO",
        //"prefix_length"=> 2,
        //"max_expansions"=> 100,
    ];

}