Laravel Searchable

v 1.4.*

Setup

Adding the Trait to Your Model

To make a model searchable, import and use the Searchable trait:

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use NahidFerdous\Searchable\Searchable;

class User extends Authenticatable
{
    use Searchable;
    
    // Define your relationships as usual
    public function country()
    {
        return $this->belongsTo(Country::class);
    }
    
    public function posts()
    {
        return $this->hasMany(Post::class);
    }
}

That's it! Your model is now ready to use the searchable features.