TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'], ] ] ]; } /** * @inheritdoc */ public function rules() { return [ [['store_id', 'start_time', 'end_time', 'created_at','is_send','send_time','commit_time' ,'number'], 'integer'], [[ 'reward_amount'], 'number'], [['created_at'], 'safe'] ]; } public static function getBonusPool($store_id, $params = [], $field = '*') { $query = self::find()->where(['store_id' => $store_id]); if ($params) { $query->andWhere($params); } $data = $query->select($field)->orderBy('id desc')->asArray()->all(); foreach ($data as &$item) { if (isset($item['start_time']) && isset($item['end_time'])) { $item['instalments'] = date("Y-m-d", $item['start_time']) . '~' . date("Y-m-d", $item['end_time']); } } return $data; } }