mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-14 11:18:23 +01:00
38 lines
832 B
PHP
38 lines
832 B
PHP
<?php
|
|
|
|
namespace yii\debug\models\search;
|
|
|
|
use yii\base\Model;
|
|
use yii\debug\components\search\Filter;
|
|
use yii\debug\components\search\matches;
|
|
|
|
class Base extends Model
|
|
{
|
|
|
|
/**
|
|
* @param Filter $filter
|
|
* @param string $attribute
|
|
* @param boolean $partial
|
|
*/
|
|
public function addCondition($filter, $attribute, $partial = false)
|
|
{
|
|
$value = $this->$attribute;
|
|
|
|
if (mb_strpos($value, '>') !== false) {
|
|
|
|
$value = intval(str_replace('>', '', $value));
|
|
$filter->addMatch($attribute, new matches\Greater(['value' => $value]));
|
|
|
|
} elseif (mb_strpos($value, '<') !== false) {
|
|
|
|
$value = intval(str_replace('<', '', $value));
|
|
$filter->addMatch($attribute, new matches\Lower(['value' => $value]));
|
|
|
|
} else {
|
|
$filter->addMatch($attribute, new matches\Exact(['value' => $value, 'partial' => $partial]));
|
|
}
|
|
|
|
}
|
|
|
|
}
|