remoblaser/search 问题修复 & 功能扩展

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

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

remoblaser/search

最新稳定版本:v0.3

Composer 安装命令:

composer require remoblaser/search

包简介

A simple to implement Search for your Application

README 文档

README

Install With Composer

"require": {
    "remoblaser/search": "^0.3.0"
}

Configure the app

Add the service provider to config/app.php.

'providers' => array(
		...
        'Remoblaser\Search\SearchServiceProvider',
	),

Register the alias in the app/config/app.php file.

'aliases' => array(
    ...
    'Search' => 'Remoblaser\Search\Facades\Search'
	),

Publish the configuration

php artisan vendor:publish

Usage

After publishing the config, you will find a config file under app/packages/remoblaser/search/config.php, bind your Models to a key here, if you have a Posts table for example, add it here:

return array(
    'users' => 'User',
    'posts' => 'My\Sample\Namespace\Post'
);

Afterwards you have to implement the SearchableTrait in your Model and define the Fields which you would like to search. In this example i would like to search through the titles and the bodies.

<?php namespace My\Sample\Namespace;

use Remoblaser\Search\SearchableTrait;

class Post extends \Eloquent{
    use SearchableTrait;

    protected $searchFields = ['title', 'body'];
}

Now you can Search through your Tables from anywhere in your application by using the Search Facade, followed by the binding key.

Search::posts('bla')

Or you could search all registered Tables for the Keyword.

Search::all('bla')

Feel free to make pull requests, this is my first laravel package so im sure i did things badly

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-26