Base.php 450 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\db\Builder;use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class Base extends Model
  9. {
  10. /**
  11. * @var array|string[]
  12. */
  13. protected static function boot()
  14. {
  15. parent::boot();
  16. // 应用全局作用域:未删除记录
  17. static::addGlobalScope('isDel', function (Builder $builder) {
  18. $builder->where('is_del', 0);
  19. });
  20. }
  21. }