Example of Nicolaslopezj/searchable in agorakit/agorakit

File composer.json (link to Github)
{
  "require": {
    "php": "^7.3",
    //
    "nicolaslopezj/searchable": "^1"
  },
}
File app/Discussion.php (link to Github)
use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait;

class Discussion extends Model
{
    use SearchableTrait;

    protected $searchable = [
        'columns' => [
            'discussions.name'    => 10,
            'discussions.body'    => 10,
        ],
    ];
}
File app/File.php (link to Github)
use Nicolaslopezj\Searchable\SearchableTrait;

class File extends Model
{
    use SearchableTrait;

    protected $searchable = [
        'columns' => [
            'files.name'    => 10,
        ],
    ];
}
File app/Http/Controllers/SearchController.php (link to Github)
class SearchController extends Controller
{
    public function index(Request $request)
    {
        if ($request->get('query')) {
            $query = $request->get('query');

            $discussions = \App\Discussion::whereIn('group_id', $allowed_groups)
            ->with('group')
            ->search($query)
            ->orderBy('updated_at', 'desc')
            ->paginate(20, ['*'], 'discussions');

            $files = \App\File::whereIn('group_id', $allowed_groups)
            ->with('group')
            ->search($query)
            ->orderBy('updated_at', 'desc')
            ->paginate(20, ['*'], 'files');
            //
    }
}