承接 acadea/fullsite-search 相关项目开发

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

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

acadea/fullsite-search

Composer 安装命令:

composer require acadea/fullsite-search

包简介

Laravel package to perform full site search based on Laravel Scout

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Laravel package to perform full site search based on Laravel Scout. Bringing the search everything box to live in a laravel app.

Support us

Learn the idea behind this package in my:

Follow us on Youtube: https://www.youtube.com/channel/acadeaio

Buy us a coffee: https://www.buymeacoffee.com/acadea

Paypal: https://www.paypal.com/donate/?hosted_button_id=HPD9HHN3HBPDC

Quick Start

// Expect a collection of models in the search result
$results = \Acadea\FullSite\FullSiteSearch::search('in');

Each model returned has 3 additional attributes:

  • a. match -- the match + neighbouring text found from our DB records
  • b. model -- the related model name
  • c. view_link -- the URL for the user to navigate in the frontend to view the resource

To return the results as an API response:

// Controller
return \Acadea\FullSite\Resources\SiteSearchResource::collection($results);

For your convenience, we have bootstrapped the API endpoint for you. You can disable this in the config file. Just set the fullsite-search.api.disabled config to true.

Example:

URL: /api/site-search?search=in

We get:

{
    "data": [
        {
            "id": 2,
            "match": "...ER happen in a frighte...",
            "model": "Post",
            "view_link": "http://127.0.0.1:8000/posts/2"
        },
        {
            "id": 4,
            "match": "Drawling, Stretching, ...",
            "model": "Post",
            "view_link": "http://127.0.0.1:8000/posts/4"
        },
        {
            "id": 6,
            "match": "...ed to her in the dista...",
            "model": "Post",
            "view_link": "http://127.0.0.1:8000/posts/6"
        }
    ]
}

Installation

You can install the package via composer:

composer require acadea/fullsite-search

You can publish the config file with:

php artisan vendor:publish --provider="Acadea\FullSite\FullSiteServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    // path to your models directory, relative to /app
    'model_path' => 'Models',

    'api' => [
        // enable api endpoint
        'disabled' => false,
        // the api endpoint uri
        'url' => '/api/site-search',
    ],

    // you can put any models that you want to exclude from the search here
    'exclude' => [
        // example:
        // \App\Models\Comment::class
    ],

    // the number of neighbouring characters that you want to include in the match field of API response
    'buffer' => 10,

    // this is where you define where should the search result leads to.
    // the link should navigate to the resource view page
    // by default, we use `/<model-name>/<model-id>` , you can define anything here
    // We will replace `{id}` or `{ id }` with the model id
    'view_mapping' => [
        // \App\Models\Comment::class => '/comments/view/{id}'
    ],
];

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 31
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固