Rule.php 961 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. protected $guarded = ['id'];
  11. public function getTypeLabelAttribute(): string {
  12. switch($this->attributes['type']){
  13. case 1:
  14. $type_label = '正则表达式';
  15. break;
  16. case 2:
  17. $type_label = '域 名';
  18. break;
  19. case 3:
  20. $type_label = 'I P';
  21. break;
  22. case 4:
  23. $type_label = '协 议';
  24. break;
  25. default:
  26. $type_label = '未 知';
  27. }
  28. return $type_label;
  29. }
  30. public function getTypeApiLabelAttribute(): string {
  31. switch($this->attributes['type']){
  32. case 1:
  33. $type_api_label = 'reg';
  34. break;
  35. case 2:
  36. $type_api_label = 'domain';
  37. break;
  38. case 3:
  39. $type_api_label = 'ip';
  40. break;
  41. case 4:
  42. $type_api_label = 'protocol';
  43. break;
  44. default:
  45. $type_api_label = 'unknown';
  46. }
  47. return $type_api_label;
  48. }
  49. }