承接 soliyer/laravel-fuzzy-search 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soliyer/laravel-fuzzy-search

Composer 安装命令:

composer require soliyer/laravel-fuzzy-search

包简介

A Laravel package providing a fuzzy search trait for Eloquent models to easily implement search functionality with support for concatenated attributes.

README 文档

README

This Laravel package provides a FuzzySearchable trait for Eloquent models, enabling easy implementation of search functionality with support for concatenated attributes. It's designed to enhance search experiences in Laravel applications by allowing more flexible and user-friendly search queries, including partial matches and concatenated field searches.

Installation

To install the package via Composer, run the following command:

composer require soliyer/laravel-fuzzy-search

Make sure your Laravel version is compatible with this package by checking the Laravel version requirements in the composer.json.

Usage

Basic Usage

To add fuzzy search capabilities to your Eloquent models, simply use the FuzzySearchable trait and define the attributes you want to make searchable:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Soliyer\LaravelFuzzySearch\Traits\FuzzySearchable;

class Post extends Model
{
    use FuzzySearchable;

    protected $fillable = ['title', 'body', 'author', 'first_name', 'last_name'];

    // Specify the attributes you want to make searchable
    protected $searchable_attributes = ['title', 'body'];
}

You can now perform fuzzy searches on your model like so:

$posts = Post::fuzzySearch('Laravel')->get();

This will search the title and body attributes of the Post model for the term 'Laravel', allowing for partial matches and enhancing the search experience.

Searching Concatenated Attributes If you want to search across concatenated attributes (e.g., first and last name), define your searchable attributes as follows:

protected $searchable_attributes = [
    ['first_name', 'last_name'], // This will concatenate first_name and last_name with a space in between
    'email',
    'company'
];

Key Points:

  • Fillable Array: This is just an example. Replace or remove the $fillable property based on your actual model requirements.
  • Searchable Attributes: Adapt the protected $searchable_attributes array to match the specific attributes you wish to make searchable in your models.

Then, performing a fuzzy search will include these concatenated fields in the search criteria.

Advanced Usage

The FuzzySearchable trait is flexible; you can further customize search behavior by extending the trait or directly in your model methods.

Contributing

Contributions are welcome and fully credited. Please feel free to fork the repository, make your changes, and submit a pull request on GitHub.

For major changes, please open an issue first to discuss what you would like to change. Make sure to update tests as appropriate.

Security

If you discover any security-related issues, please email vafaei39@gmail.com instead of using the public issue tracker.

Credits

Soheil Vafaei - Package Author Special thanks to all contributors who participated in the development of this package.

License

The Laravel Fuzzy Search package is open-sourced software licensed under the MIT license.

soliyer/laravel-fuzzy-search 适用场景与选型建议

soliyer/laravel-fuzzy-search 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 soliyer/laravel-fuzzy-search 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 soliyer/laravel-fuzzy-search 我们能提供哪些服务?
定制开发 / 二次开发

基于 soliyer/laravel-fuzzy-search 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-03