qrstuff/scout-mongodb 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

qrstuff/scout-mongodb

最新稳定版本:1.0.1

Composer 安装命令:

composer require qrstuff/scout-mongodb

包简介

MongoDB (not MongoDB Atlas) engine for the Laravel Scout search.

README 文档

README

MongoDB (not MongoDB Atlas) engine for the Laravel Scout search.

Latest Version Downloads PHP Version License

Installation

composer require qrstuff/scout-mongodb

Usage

Before following this guide, make sure you have installed and set up laravel/scout in your project already.

In your config/database.php, add the mongodb connection:

return [

    // other stuff

    'connections' => [

        // other stuff

        'mongodb' => [
            'driver' => 'mongodb',
            'dsn' => env('MONGODB_URL'),
            'database' => env('MONGODB_DATABASE', 'example'),
        ],

    ],

    // other stuff

];

In your config/scout.php, add the mongodb definition:

return [

    // other stuff

    'mongodb' => [
        'connection' => env('SCOUT_MONGODB_CONNECTION', 'mongodb'),
        'index-settings' => [
            // App\Models\User::class => [
            //     'searchableAttributes'=> ['name', 'email', 'phone'],
            //     'filterableAttributes'=> [['country' => 1]], // 1 = ASC, 2 = DESC
            // ],
        ],
    ],

    // other stuff

];

Then add the Searchable trait your model classes as follows:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class Customer extends Model
{
    use Searchable; // include the trait
}

You can now search across your models as below:

use App\Models\Customer;

$customersInIndia = Customer::search('vpz')->where('country', 'IN')->get();

License

See LICENSE file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固