1. Go to this page and download the library: Download sdfsky/tipask-xunsearch 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/ */
use Illuminate\Database\Eloquent\Model;
use DavinBao\LaravelXunSearch\Model\SearchableInterface;
class Dummy extends Model implements SearchableInterface
{
// ...
/**
* Get id list for all searchable models.
*/
public static function searchableIds()
{
return self::wherePublish(true)->lists('id');
}
// ...
}
use Illuminate\Database\Eloquent\Model;
use DavinBao\LaravelXunSearch\Model\SearchableInterface;
use DavinBao\LaravelXunSearch\Model\SearchTrait;
class Dummy extends Model implements SearchableInterface
{
use SearchTrait;
// ...
}
$query = Model::getSearch()->addQuery("clock"); // search by all fields.
// or
$query = Model::getSearch()->addQuery('name:clock'); // search by 'name' field.
// or
$query = Model::getSearch()->addQuery('name:clock'); // filter by 'short_description' field.
$Ids = Model::getSearch()->addQuery('name:clock')->getIDList(); // filter by 'short_description' field.