devhereco/simple-eloquent-search

A Laravel package for adding search functionality to models.

2.0 2024-07-01 18:25 UTC

This package is auto-updated.

Last update: 2024-10-01 00:07:35 UTC


README

A laravel package to search via your models .

installation : composer require devhereco/simple-eloquent-search

Usage :

  • use Searchable trait in your model
  • Define $searchable property in your model to select which columns to search in

Example :

use devhereco\SimpleEloquentSearch\Searchable;

class User extends Model {

  use Searchable ;
  protected $searchable = ['name', 'posts.title'];
  
  public function posts(){
    return $this->hasMany(Post::class);
  }
}

// Calling search method
Model::search('ABC')->get();