Rule.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Builder;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 审计规则
  7. *
  8. * @property int $id
  9. * @property int $type 类型:1-正则表达式、2-域名、3-IP、4-协议
  10. * @property string $name 规则描述
  11. * @property string $pattern 规则值
  12. * @property \Illuminate\Support\Carbon $created_at
  13. * @property \Illuminate\Support\Carbon $updated_at
  14. * @property-read mixed $type_label
  15. * @method static Builder|Rule newModelQuery()
  16. * @method static Builder|Rule newQuery()
  17. * @method static Builder|Rule query()
  18. * @method static Builder|Rule whereCreatedAt($value)
  19. * @method static Builder|Rule whereId($value)
  20. * @method static Builder|Rule whereName($value)
  21. * @method static Builder|Rule wherePattern($value)
  22. * @method static Builder|Rule whereType($value)
  23. * @method static Builder|Rule whereUpdatedAt($value)
  24. * @mixin \Eloquent
  25. */
  26. class Rule extends Model {
  27. protected $table = 'rule';
  28. protected $primaryKey = 'id';
  29. function getTypeLabelAttribute() {
  30. switch($this->attributes['type']){
  31. case 1:
  32. $type_label = '正则表达式';
  33. break;
  34. case 2:
  35. $type_label = '域 名';
  36. break;
  37. case 3:
  38. $type_label = 'I P';
  39. break;
  40. case 4:
  41. $type_label = '协 议';
  42. break;
  43. default:
  44. $type_label = '未 知';
  45. }
  46. return $type_label;
  47. }
  48. }