80 lines
2.5 KiB
Markdown
80 lines
2.5 KiB
Markdown
ArrayQuery Component for Yii2
|
|
=============================
|
|
|
|
[](https://github.com/2amigos/yii2-arrayquery-component/tags)
|
|
[](LICENSE.md)
|
|
[](https://travis-ci.org/2amigos/yii2-arrayquery-component)
|
|
[](https://scrutinizer-ci.com/g/2amigos/yii2-arrayquery-component/code-structure)
|
|
[](https://scrutinizer-ci.com/g/2amigos/yii2-arrayquery-component)
|
|
[](https://packagist.org/packages/2amigos/yii2-arrayquery-component)
|
|
|
|
Allows searching/filtering of an array. This component is very useful when displaying array data in GridViews with an
|
|
ArrayDataProvider.
|
|
|
|
Installation
|
|
------------
|
|
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
|
|
|
|
Either run
|
|
|
|
```
|
|
php composer.phar require "2amigos/yii2-arrayquery-component" "*"
|
|
```
|
|
or add
|
|
|
|
```
|
|
"2amigos/yii2-arrayquery-component" : "*"
|
|
```
|
|
|
|
to the require section of your application's `composer.json` file.
|
|
|
|
Usage
|
|
-----
|
|
|
|
```
|
|
\\ $models is the array elements to used with ArrayDataProvider
|
|
|
|
$query = new ArrayQuery($models);
|
|
|
|
$models = $query
|
|
->addCondition('name', '~2amigos')
|
|
->addCondition('name', 'cebe/yii2-gravatar', 'or')
|
|
->find();
|
|
|
|
$dataProvider = new ArrayDataProvider([
|
|
'allModels' => $models,
|
|
'pagination' => [
|
|
'pageSize' => 50,
|
|
],
|
|
'sort' => [
|
|
'attributes' => [], // to be specified
|
|
],
|
|
]);
|
|
|
|
```
|
|
|
|
## Testing
|
|
|
|
``` bash
|
|
$ phpunit
|
|
```
|
|
|
|
## Contributing
|
|
|
|
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
|
|
|
|
## Credits
|
|
|
|
- [Antonio Ramirez](https://github.com/tonydspaniard)
|
|
- [All Contributors](../../contributors)
|
|
|
|
## License
|
|
|
|
The BSD License (BSD). Please see [License File](LICENSE.md) for more information.
|
|
|
|
|
|
> [](http://www.2amigos.us)
|
|
|
|
<i>Custom Software | Web & Mobile Software Development</i>
|
|
[www.2amigos.us](http://www.2amigos.us)
|