RuleGroup.php 745 B

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