vintage/yii2-search 问题修复 & 功能扩展

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

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

vintage/yii2-search

Composer 安装命令:

composer require vintage/yii2-search

包简介

Search in Active Record models for Yii2

README 文档

README

Search in Active Record models for Yii2

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version

This is component for searching in the Active Record models for Yii2 Framework.

Documentation is at docs/guide/README.md.

Installation

Install package

The preferred way to install this extension is through composer.

Either run

$ composer require vintage/yii2-search

or add

"vintage/yii2-search": "~2.0"

to the require section of your composer.json.

Usage

Implement \vintage\search\interfaces\SearchInterface interface in Active Record models

/**
 * Article search model.
 * 
 * @property integer $id
 * @property string $title
 * @property string $short_description
 * @property string $content
 */
class ArticleSearch extends ActiveRecord implements \vintage\search\interfaces\SearchInterface
{
    /**
     * @inheritdoc
     */
    public function getSearchTitle()
    {
    
        return $this->title;
    }

    /**
     * @inheritdoc
     */
    public function getSearchDescription()
    {
        return $this->short_description;
    }

    /**
     * @inheritdoc
     */
    public function getSearchUrl()
    {
       return Url::toRoute(['/news/default/index', 'id' => $this->id]);
    }

   /**
    * @inheritdoc
    */
    public function getSearchFields()
    {
        return [
            'title',
            'short_description',
            'content',
        ];
    }
}

Call method of search component with a query

/* @var \vintage\search\models\SearchResult[] $result */
$result = Yii::$app->get('searcher')->search('some query here');

this method returns array of \vintage\search\models\SearchResult objects.

Tests

You can run tests with composer command

$ composer test

or using following command

$ codecept build && codecept run

Contributing

For information about contributing please read CONTRIBUTING.md.

Licence

License

This project is released under the terms of the BSD-3-Clause license.

统计信息

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

GitHub 信息

  • Stars: 29
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-04-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固