PHP code example of eloquage / scout-lunr
1. Go to this page and download the library: Download eloquage/scout-lunr 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/ */
eloquage / scout-lunr example snippets
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
class Post extends Model
{
use Searchable;
public function toSearchableArray(): array
{
return ['title' => $this->title, 'body' => $this->body];
}
}
$posts = Post::search('laravel')->take(10)->get();
$published = Post::search('laravel')->where('status', 'published')->get();
use IllumaLaw\ScoutLunr\Query\LunrQueryBuilder;
$query = LunrQueryBuilder::make()
->:search($query)->get();