RuleGroup.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 array|null $rules 关联的规则ID,多个用,号分隔
  12. * @property array|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. protected $casts = [
  31. 'rules' => 'array',
  32. 'nodes' => 'array'
  33. ];
  34. public function getTypeLabelAttribute(): string {
  35. if($this->attributes['type']){
  36. $type_label = '<span class="badge badge-danger">阻 断</span>';
  37. }else{
  38. $type_label = '<span class="badge badge-primary">放 行</span>';
  39. }
  40. return $type_label;
  41. }
  42. }