return QueryBuilder::for(MyModel::query())
->where('is_disabled', false)
->allowedFields([
...
])
->allowedFilters([
...
])
->defaultSort(AllowedSort::custom('campaign', new SaleCampaignSort))
->allowedSorts([
...
])
->with(['entities'])
->when(
$this->data('with'),
fn (BuilderContract $builder) => $builder->with($this->data('with')),
)
->when(
$this->data('scopes'),
function (BuilderContract $builder) {
foreach ($this->data('scopes') as $scope => $parameters) {
if (is_int($scope)) {
$builder->$parameters();
continue;
}
$builder->$scope(...$parameters);
}
}
);