File: /home/aliazzsr/api.crm.vqode.com/components/filtering/SimpleCondition.php
<?php
namespace app\components\filtering;
use app\components\BaseModel;
use app\components\formatters\DateFormatter;
use yii\helpers\ArrayHelper;
class SimpleCondition extends BaseCondition
{
/**
* @inheritdoc
*/
public static function get($attribute, $value, $modelClass)
{
/** @var BaseModel $modelClass */
$attributes = $modelClass::getTableSchema()->columns;
$dbAttr = ArrayHelper::getValue($attributes, $attribute);
switch ($dbAttr->type) {
case 'timestamp':
$condition = ['=', static::getDateAttribute($dbAttr->name), DateFormatter::toMysql($value)];
break;
default:
$condition = [$attribute => $value];
}
return $condition;
}
/**
* @inheritdoc
*/
public static function is($attribute, $value)
{
return is_scalar($value);
}
}