AuditMedia.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Events;
  3. use App\Exceptions\AlertException;
  4. use App\Models\Media\MediaSecureImage;
  5. use App\Models\Media\MediaSecureText;
  6. use App\Models\Media\MediaSecureVoice;
  7. use App\Models\Model;
  8. /**
  9. * 提交审核素材事件
  10. * Class AuditMedia
  11. * @package App\Events
  12. */
  13. class AuditMedia
  14. {
  15. public $uid;
  16. public $type;
  17. public $origin;
  18. /**
  19. * @var model
  20. */
  21. public $storage;
  22. public $field;
  23. public $field_primary;
  24. public $failCallback;
  25. public $succCallback;
  26. /**
  27. * Create a new event instance.
  28. *
  29. * @param int $uid
  30. * @param string $type
  31. * @param string $origin
  32. * @param string $field
  33. * @param null $field_primary
  34. * @param \Closure|string $failCallback
  35. * @param \Closure|string $succCallback
  36. * @throws AlertException
  37. */
  38. public function __construct(
  39. int $uid,
  40. string $type,
  41. string $origin,
  42. string $field,
  43. $field_primary = null,
  44. $failCallback = null,
  45. $succCallback = null
  46. ) {
  47. $this->uid = $uid;
  48. $this->type = $type;
  49. $this->origin = $origin;
  50. $this->field = $field;
  51. $this->field_primary = $field_primary;
  52. $this->failCallback = $failCallback;
  53. $this->succCallback = $succCallback;
  54. $this->validateType();
  55. }
  56. public function validateType()
  57. {
  58. switch ($this->type) {
  59. case "text":
  60. $this->storage = new MediaSecureText();
  61. break;
  62. case "image":
  63. $this->storage = new MediaSecureImage();
  64. break;
  65. case "voice":
  66. $this->storage = new MediaSecureVoice();
  67. break;
  68. }
  69. }
  70. }