Common.php 854 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/18
  6. * Time: 下午7:46
  7. */
  8. namespace common\models;
  9. use yii\db\ActiveRecord;
  10. use yii\behaviors\TimestampBehavior;
  11. class Common extends ActiveRecord
  12. {
  13. protected $setDel = 1;
  14. public function behaviors()
  15. {
  16. return [
  17. [
  18. 'class' => TimestampBehavior::className(),
  19. 'attributes' => [
  20. # 创建之前
  21. ActiveRecord::EVENT_BEFORE_INSERT => ['create_at', 'update_at'],
  22. # 修改之前
  23. ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at']
  24. ],
  25. #设置默认值
  26. 'value' => $_SERVER['REQUEST_TIME']
  27. ]
  28. ];
  29. }
  30. public function setDelete($num)
  31. {
  32. $this->setDel = $num;
  33. }
  34. }