定制 sciku1/laravel-match-against 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sciku1/laravel-match-against

Composer 安装命令:

composer require sciku1/laravel-match-against

包简介

Laravel builder match against eloquent syntax and related.

README 文档

README

A simple macro for doing match against fulltext searches with the Eloquent ORM api, currently in beta.

Requirements

  • Laravel 5.x
  • MySQL 3.3+

composer require sciku1/laravel-match-against

Laravel 5.5

You're done!

Laravel 5.x

You must register the service provider in your config/app.php

'providers' => [
    ...
    Sciku1\LaravelMatchAgainst\Providers\MatchAgainstServiceProvider::class,
]

Usage

To run match against queries, the field must have a fulltext index, currently there only way to do this is

DB::statement('ALTER TABLE `table_name` ADD FULLTEXT index_name(col1, col2)');

Order

The default behaviour is to order. Example:

Model::match(['col1', 'col2'])->against('search terms')->get();

will generate

SELECT * FROM models ORDER BY (MATCH (col1) AGAINST ('search terms')) DESC, (MATCH (col2) AGAINST ('search terms')) DESC

Where

To limit the results, you must use whereAgainst()

Model::match(['col1', 'col2'])->whereAgainst('search terms')->get();

will generate

SELECT * FROM models WHERE (MATCH (col1) AGAINST ('search terms')) > 0, (MATCH (col2) AGAINST ('search terms')) > 0

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固