DummyWithGlobalScope.php 692 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Spatie\EloquentSortable\Test;
  3. use Illuminate\Database\Eloquent\Builder;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Spatie\EloquentSortable\Sortable;
  6. use Spatie\EloquentSortable\SortableTrait;
  7. class DummyWithGlobalScope extends Model implements Sortable
  8. {
  9. use SortableTrait;
  10. protected $table = 'dummies';
  11. protected $guarded = [];
  12. public $timestamps = false;
  13. /**
  14. * The "booting" method of the model.
  15. *
  16. * @return void
  17. */
  18. protected static function boot()
  19. {
  20. parent::boot();
  21. parent::addGlobalScope('ActiveScope', function (Builder $builder) {
  22. $builder->where('is_active', true);
  23. });
  24. }
  25. }