Rule.php 807 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 = [];
  12. public function getTypeLabelAttribute(): string
  13. {
  14. return [
  15. 1 => '正则表达式',
  16. 2 => '域 名',
  17. 3 => 'I P',
  18. 4 => '协 议',
  19. ][$this->attributes['type']] ?? '未 知';
  20. }
  21. public function getTypeApiLabelAttribute(): string
  22. {
  23. return [
  24. 1 => 'reg',
  25. 2 => 'domain',
  26. 3 => 'ip',
  27. 4 => 'protocol',
  28. ][$this->attributes['type']] ?? 'unknown';
  29. }
  30. public function rule_groups()
  31. {
  32. return $this->belongsToMany(RuleGroup::class);
  33. }
  34. }