RelationValidate.php 622 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace addons\BusinessCard\common\validate;
  3. use addons\BusinessCard\common\models\BusinessCardCustomerLog;
  4. class RelationValidate
  5. {
  6. /**
  7. * @param array $data [item_id, user_id, log_type, mall_id]
  8. * @return array|\yii\db\ActiveRecord|null
  9. */
  10. public static function valid(array $data)
  11. {
  12. return BusinessCardCustomerLog::find()
  13. ->where(['mall_id' => $data['mall_id']])
  14. ->andWhere(['item_id' => $data['item_id']])
  15. ->andWhere(['user_id' => $data['user_id']])
  16. ->andWhere(['log_type' => $data['log_type']])
  17. ->one();
  18. }
  19. }