PHP code example of dvsoftsrl / eloquent-searchable

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

    

dvsoftsrl / eloquent-searchable example snippets




namespace App;

use Illuminate\Database\Eloquent\Model;
use DvSoft\EloquentSearchable\EloquentSearchableTrait;

class Post extends Model
{
    use EloquentSearchableTrait;
    
    // You can specify the columns to search on
    protected $searchable = ['tile', 'excerpt'];
}

    $posts = Post::search($query)->get();

    $posts = Post::where('published', true)->search($query)->paginate();

    $posts = Post::search($query, true)->get();