Rule.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 审计规则.
  6. */
  7. class Rule extends Model
  8. {
  9. public $timestamps = false;
  10. protected $table = 'rule';
  11. protected $guarded = ['id'];
  12. public function getTypeLabelAttribute(): string
  13. {
  14. switch ($this->attributes['type']) {
  15. case 1:
  16. $type_label = '正则表达式';
  17. break;
  18. case 2:
  19. $type_label = '域 名';
  20. break;
  21. case 3:
  22. $type_label = 'I P';
  23. break;
  24. case 4:
  25. $type_label = '协 议';
  26. break;
  27. default:
  28. $type_label = '未 知';
  29. }
  30. return $type_label;
  31. }
  32. public function getTypeApiLabelAttribute(): string
  33. {
  34. switch ($this->attributes['type']) {
  35. case 1:
  36. $type_api_label = 'reg';
  37. break;
  38. case 2:
  39. $type_api_label = 'domain';
  40. break;
  41. case 3:
  42. $type_api_label = 'ip';
  43. break;
  44. case 4:
  45. $type_api_label = 'protocol';
  46. break;
  47. default:
  48. $type_api_label = 'unknown';
  49. }
  50. return $type_api_label;
  51. }
  52. }