1
0

RuleGroup.php 678 B

1234567891011121314151617181920212223242526272829
  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 rules(): BelongsToMany
  13. {
  14. return $this->belongsToMany(Rule::class);
  15. }
  16. public function getTypeLabelAttribute(): string
  17. {
  18. return match ($this->type) {
  19. 0 => '<span class="badge badge-primary">'.trans('admin.rule.group.type.on').'</span>',
  20. 1 => '<span class="badge badge-danger">'.trans('admin.rule.group.type.off').'</span>',
  21. };
  22. }
  23. }