コード例 #1
0
ファイル: Message.php プロジェクト: EugeneBogun/dashboard
 public function fields()
 {
     $fields = parent::fields();
     unset($fields['createdAt'], $fields['updatedAt']);
     $fields['date'] = function () {
         return $this->createdAt;
     };
     $fields['data'] = function () {
         return Json::decode($this->data);
     };
     return $fields;
 }
コード例 #2
0
 public static function getStatusLabels()
 {
     return ArrayHelper::merge(parent::getStatusLabels(), [self::STATUS_CREATED => '已创建', self::STATUS_PAID => '已支付', self::STATUS_DELIVERY => '已发货', self::STATUS_SUCCESS => '已完成', self::STATUS_SUCCESS => '已退款']);
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['ts'] = ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at'];
     return $behaviors;
 }
コード例 #4
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return parent::attributeLabels();
 }
コード例 #5
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->level = static::calculateLevel($this);
         return true;
     } else {
         return false;
     }
 }
コード例 #6
0
ファイル: Bookmark.php プロジェクト: jc21/snippets-site
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'memberId', 'snippetId', 'createdTime', 'updatedTime']]];
     return array_merge(parent::behaviors(), $behaviours);
 }
コード例 #7
0
ファイル: _form.php プロジェクト: su-xiaolin/ICShop-Yii
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'type')->dropDownList(ProductAttribute::getTypeLabels());
?>

    <?php 
echo $form->field($model, 'option')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ActiveRecord::getStatusLabels());
?>
    
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-6">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-block btn-success' : 'btn btn-block btn-primary']);
?>
        </div>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
コード例 #8
0
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), [TimestampBehavior::className(), 'trim' => ['class' => TrimBehavior::className(), 'attributes' => ['attribute_option']]]);
 }
コード例 #9
0
ファイル: Member.php プロジェクト: jc21/snippets-site
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'lastSeenTime', 'createdTime', 'updatedTime'], 'boolFields' => ['isActive', 'isAdmin']]];
     return array_merge(parent::behaviors(), $behaviours);
 }
コード例 #10
0
 public function setAttribute($name, $value)
 {
     if ($this->owner->hasAttribute($name)) {
         $this->owner->setAttribute($name, $value);
     }
 }
コード例 #11
0
ファイル: Snippet.php プロジェクト: jc21/snippets-site
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'languageId', 'memberId', 'views', 'downloads', 'createdTime', 'updatedTime'], 'boolFields' => ['isHidden']]];
     return array_merge(parent::behaviors(), $behaviours);
 }