RuleGroup.php 610 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 审计规则分组.
  6. */
  7. class RuleGroup extends Model
  8. {
  9. protected $table = 'rule_group';
  10. protected $guarded = [];
  11. public function getTypeLabelAttribute(): string
  12. {
  13. if ($this->attributes['type']) {
  14. $type_label = '<span class="badge badge-danger">阻 断</span>';
  15. } else {
  16. $type_label = '<span class="badge badge-primary">放 行</span>';
  17. }
  18. return $type_label;
  19. }
  20. public function rules()
  21. {
  22. return $this->belongsToMany(Rule::class);
  23. }
  24. }