Rule.php 931 B

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