RuleGroup.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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-阻断、0-放行
  10. * @property string $name 分组名称
  11. * @property string|null $rules 关联的规则ID,多个用,号分隔
  12. * @property string|null $nodes 关联的节点ID,多个用,号分隔
  13. * @property \Illuminate\Support\Carbon $created_at 创建时间
  14. * @property \Illuminate\Support\Carbon $updated_at 最后更新时间
  15. * @property-read string $type_label
  16. * @method static Builder|RuleGroup newModelQuery()
  17. * @method static Builder|RuleGroup newQuery()
  18. * @method static Builder|RuleGroup query()
  19. * @method static Builder|RuleGroup whereCreatedAt($value)
  20. * @method static Builder|RuleGroup whereId($value)
  21. * @method static Builder|RuleGroup whereName($value)
  22. * @method static Builder|RuleGroup whereNodes($value)
  23. * @method static Builder|RuleGroup whereRules($value)
  24. * @method static Builder|RuleGroup whereType($value)
  25. * @method static Builder|RuleGroup whereUpdatedAt($value)
  26. * @mixin \Eloquent
  27. */
  28. class RuleGroup extends Model {
  29. protected $table = 'rule_group';
  30. public function getTypeLabelAttribute(): string {
  31. if($this->attributes['type']){
  32. $type_label = '<span class="badge badge-danger">阻 断</span>';
  33. }else{
  34. $type_label = '<span class="badge badge-primary">放 行</span>';
  35. }
  36. return $type_label;
  37. }
  38. }