Skip to content

Commit 04fd0ed

Browse files
authored
Merge pull request #70 from alfa6661/features/has-scopes
[4.0] Added hasScopes method.
2 parents dbde853 + d57d2ec commit 04fd0ed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Services/DataTable.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,23 @@ protected function applyScopes($query)
570570
return $query;
571571
}
572572

573+
/**
574+
* Determine if the DataTable has scopes.
575+
*
576+
* @param array $scopes
577+
* @param bool $validateAll
578+
* @return bool
579+
*/
580+
protected function hasScopes(array $scopes, $validateAll = false)
581+
{
582+
$filteredScopes = array_filter($this->scopes, function ($scope) use ($scopes) {
583+
return in_array(get_class($scope), $scopes);
584+
});
585+
586+
return $validateAll ? count($filteredScopes) === count($scopes) :
587+
! empty($filteredScopes);
588+
}
589+
573590
/**
574591
* Get default builder parameters.
575592
*

0 commit comments

Comments
 (0)