1. Go to this page and download the library: Download jabbtech/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/ */
jabbtech / searchable example snippets
namespace App;
use Illuminate\Database\Eloquent\Model;
use Jabbtech\Searchable\SearchableTrait;
class User extends Model
{
use SearchableTrait;
protected $searchable = [
'columns' => [
'users.first_name' => 10,
'users.last_name' => 10,
'users.bio' => 2,
'users.email' => 5,
'posts.title' => 2,
'posts.body' => 1,
],
'joins' => [
'posts' => ['users.id','posts.user_id'],
],
];
public function posts()
{
return $this->hasMany('App\Post');
}
}