MerchantBehavior.php 619 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace common\behaviors;
  3. use Yii;
  4. use yii\behaviors\BlameableBehavior;
  5. use yii\db\ActiveRecord;
  6. /**
  7. * Trait MerchantBehavior
  8. * @package common\components
  9. */
  10. trait MerchantBehavior
  11. {
  12. /**
  13. * @return array
  14. */
  15. public function behaviors()
  16. {
  17. $behaviors = parent::behaviors();
  18. $behaviors[] = [
  19. 'class' => BlameableBehavior::class,
  20. 'attributes' => [
  21. ActiveRecord::EVENT_BEFORE_INSERT => ['merchant_id'],
  22. ],
  23. 'value' => Yii::$app->services->merchant->getNotNullId(),
  24. ];
  25. return $behaviors;
  26. }
  27. }
粤ICP备19079148号