laravel-searchable maintained by alirezaghasemi
Description
A Laravel package for adding search functionality to models.
Author
Last update
2023/03/27 11:59
(dev-main)
License
Downloads
13
Tags
laravelSearchable
A Laravel package for adding search functionality to models
Installation :
composer require alirezaghasemi/laravel-searchable
Usage :
- use
Searchabletrait in your model - Define
$searchableproperty in your model to select which columns to search in
Example (User Model Relation With Post):
use AlirezaGhasemi\LaravelSearch\Searchable;
class User extends Model {
use Searchable ;
protected $searchable = ['name', 'mobile', 'posts.title','posts.comments.title'];
public function posts(){
return $this->hasMany(Post::class);
}
Example (Post Model Relation with Comment):
class Post extends Model {
public function comments(){
return $this->hasMany(Comment::class);
}