MerchantStoreBehavior.php 895 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace common\behaviors;
  3. use Yii;
  4. use yii\behaviors\BlameableBehavior;
  5. use yii\db\ActiveRecord;
  6. /**
  7. * Trait MerchantStoreBehavior
  8. * @package common\components
  9. */
  10. trait MerchantStoreBehavior
  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. $behaviors[] = [
  26. 'class' => BlameableBehavior::class,
  27. 'attributes' => [
  28. ActiveRecord::EVENT_BEFORE_INSERT => ['store_id'],
  29. ],
  30. 'value' => Yii::$app->services->store->getNotNullId(),
  31. ];
  32. return $behaviors;
  33. }
  34. }
粤ICP备19079148号