devhereco / simple-eloquent-search
A Laravel package for adding search functionality to models.
2.0
2024-07-01 18:25 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0
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();