MediaSecure.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Models\Media;
  3. use App\Models\Model;
  4. abstract class MediaSecure extends Model
  5. {
  6. //
  7. // 机器审核通过
  8. public const MACHINE_SUGGESTION_PASS = 1;
  9. // 机器审核待定
  10. public const MACHINE_SUGGESTION_REVIEW = 0;
  11. // 机器审核不通过
  12. public const MACHINE_SUGGESTION_BLOCK = -1;
  13. // 人工审核通过
  14. public const MANUAL_SUGGESTION_PASS = 1;
  15. // 人工审核待定
  16. public const MANUAL_SUGGESTION_REVIEW = 0;
  17. // 人工审核不通过
  18. public const MANUAL_SUGGESTION_BLOCK = -1;
  19. // 机器审核
  20. public const CHANNEL_MACHINE = 1;
  21. // 人工审核
  22. public const CHANNEL_MANUAL = 2;
  23. protected $dateFormat = 'U';
  24. protected $casts = array(
  25. 'machine_result' => 'array',
  26. 'labels' => 'array',
  27. );
  28. /**
  29. * 字段筛选
  30. * @param \Illuminate\Database\Eloquent\Builder $builder
  31. * @param $field
  32. * @return \Illuminate\Database\Eloquent\Builder
  33. */
  34. public function scopeOfField($builder, $field)
  35. {
  36. switch ($field) {
  37. // 图片
  38. case "avatar":
  39. $builder->where('field', 'headimgurl');
  40. break;
  41. case "photo":
  42. $builder->whereIn('field', ['photo_src', 'photo_1', 'photo_2', 'photo_3', 'photo_4']);
  43. break;
  44. // 文字
  45. case "nickname":
  46. $builder->where('field', 'nickname');
  47. break;
  48. case "question":
  49. $builder->where('field', 'question');
  50. break;
  51. case "invite_answer":
  52. $builder->where('field', 'invite_answer');
  53. break;
  54. case "introduce":
  55. $builder->where('field', 'introduce');
  56. break;
  57. // 语音
  58. case "voice":
  59. $builder->where('field', 'voice');
  60. break;
  61. case "invite_voice":
  62. $builder->where('field', 'invite_voice');
  63. break;
  64. case "invite_sing":
  65. $builder->where('field', 'invite_sing');
  66. break;
  67. }
  68. return $builder;
  69. }
  70. }