devhereco/simple-eloquent-search

一个用于在模型中添加搜索功能的 Laravel 扩展包。

2.0 2024-07-01 18:25 UTC

This package is auto-updated.

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


README

一个用于通过模型进行搜索的 Laravel 扩展包。

安装: composer require devhereco/simple-eloquent-search

使用

  • 在模型中使用 Searchable 特性
  • 在模型中定义 $searchable 属性以选择要搜索的列

示例

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