devhereco / Simple-Eloquent-Search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Eloquent Search

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();

About


Languages

Language:PHP 100.0%