2017 © Pedro Peláez
 

yii2-extension yii2-search

Component for search in Active Record models

image

black-lamp/yii2-search

Component for search in Active Record models

  • Wednesday, May 10, 2017
  • by GutsVadim
  • Repository
  • 3 Watchers
  • 2 Stars
  • 149 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 13 Versions
  • 7 % Grown

The README.md

Component for search in Active Record model

Build Status Latest Stable Version Latest Unstable Version License, (*1)

Installation

Run command, (*2)

composer require black-lamp/yii2-search

or add, (*3)

"black-lamp/yii2-search": "^2.0.0"

to the require section of your composer.json., (*4)

Add 'SiteSearch' component to application config

'components' => [
      // ...
      'search' => [
            'class' => bl\search\SearchComponent::class,
            // models where you need the search
            'models' => [
                'article' => [
                    'class' => frontend\models\Article::class,
                    'label' => 'Articles'
                 ],
                // ...
            ]
      ],
]

To models array you should to add the active record models where component will be make a search., (*5)

class it's a model's name., (*6)

label it's a title for displaying in view., (*7)

/**
 * @property integer $id
 * @property string $title
 * @property string $shortText
 * @property string $fullText
 * @property string $socialNetworksText
 */
class Article extends ActiveRecord implements \bl\search\interfaces\SearchInterface
{
    // ...

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

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

    /**
     * @inheritdoc
     */
    public function getSearchUrl() {
       return Url::toRoute["/articles/$this->id"];
    }

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

Using

Call method for getting a search results. This method return a SearchResult objects in array., (*8)

/**
 * @var \bl\search\data\SearchResult[] $result
 */
$result = Yii::$app->searcher->search('Black lamp');

foreach($result as $res) {
    $res->title;
    $res->description;
    $res->url;
}

The Versions

10/05 2017

dev-master

9999999-dev

Component for search in Active Record models

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

component yii2 search active record

10/05 2017

2.0.2

2.0.2.0

Component for search in Active Record models

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

component yii2 search active record

30/01 2017

2.0.1

2.0.1.0

Component for search in Active Record models

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

component yii2 search active record

05/01 2017

2.0.0

2.0.0.0

Component for search in Active Record models

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

component yii2 search active record

22/11 2016

1.1.1

1.1.1.0

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

component yii2 search site

22/11 2016

1.1.0

1.1.0.0

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

component yii2 search site

18/10 2016

1.0.0

1.0.0.0

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

component yii2 search site

26/09 2016

0.3.1-beta

0.3.1.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site

26/09 2016

0.3.0-beta

0.3.0.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site

22/09 2016

0.2.0-beta

0.2.0.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site

22/09 2016

0.1.1-beta

0.1.1.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site

22/09 2016

0.1.0-beta

0.1.0.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site

21/09 2016

0.0.1-beta

0.0.1.0-beta

Component for search on site for Yii2

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

yii2 search site