1. Go to this page and download the library: Download pahanini/yii2-refiner library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pahanini / yii2-refiner example snippets
public function init()
{
$this->refinerSet = new \pahanini\refiner\Set([
'refiners' => [
// standard range
'price' => [
'class' => '\pahanini\refiner\db\Range',
],
'category' => [
'class' => '\pahanini\refiner\db\Count',
],
// Select color values from another model
'onlyRedColor' => [
'refine' => function($query, $param) {
return $query->andWhere('color = "red"');
},
'all' => function($query) {
return $query->select('COUNT(*)')->andWhere('color = "red"')
}
]
]
])
}
public function actionSearch()
{
$query = Product::find()->andWhere('balance > 0');
$refinerResult = $this->refinerSet->applyTo($query);
$this->render('search', ['query' => $query, 'refiners' => $this->refinerSet->getRefinerValues()])
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.