BaseModel.php 810 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace common\models\base;
  3. use yii\db\ActiveRecord;
  4. use yii\behaviors\TimestampBehavior;
  5. use common\behaviors\SoftDeleteBehavior;
  6. /**
  7. * Class BaseModel
  8. * @package common\models\common
  9. * @author jianyan74 <751393839@qq.com>
  10. */
  11. class BaseModel extends ActiveRecord
  12. {
  13. /**
  14. * @return array
  15. */
  16. public function behaviors()
  17. {
  18. return [
  19. [
  20. 'class' => TimestampBehavior::class,
  21. 'attributes' => [
  22. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
  23. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
  24. ],
  25. ],
  26. [
  27. 'class' => SoftDeleteBehavior::class,
  28. 'attribute' => 'status'
  29. ],
  30. ];
  31. }
  32. }
粤ICP备19079148号