update os group

This commit is contained in:
pbao9
2026-02-02 09:07:33 +07:00
parent b3ad727d55
commit af71413a69
9 changed files with 182 additions and 106 deletions
@@ -15,21 +15,34 @@ class OsGroupCachedRepository extends BaseCachedRepository implements OsGroupRep
{
return $this->osGroupRepository->getModel();
}
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
{
public function filter(
array $data = [],
array $relationships = [],
array $withCount = [],
array $select = ['*'],
bool $returnQuery = false
) {
if (
$returnQuery ||
!empty($data['paginate'])
) {
return $this->osGroupRepository
->filter($data, $relationships, $withCount, $select, $returnQuery);
}
$cacheKey = $this->getCacheKey(md5(json_encode([
'filterItem' => [
'data' => $data,
'relationships' => $relationships,
'select' => $select,
'withCount' => $withCount
]
'filter' => compact('data', 'relationships', 'withCount', 'select')
])));
return Cache::remember($cacheKey, $this->cacheTime, function () use ($data, $relationships, $select, $withCount) {
return $this->osGroupRepository->filter($data, $relationships, $withCount, $select);
});
return Cache::remember(
$cacheKey,
$this->cacheTime,
fn() =>
$this->osGroupRepository
->filter($data, $relationships, $withCount, $select, $returnQuery)
);
}
public function findWithRelationships(int $id = 0, array $relationships = [],array $withCount = [], array $withSum = [])
public function findWithRelationships(int $id = 0, array $relationships = [], array $withCount = [], array $withSum = [])
{
$cacheKey = $this->getCacheKey(md5(json_encode([
'findWithRelationships' => [
@@ -37,8 +50,8 @@ class OsGroupCachedRepository extends BaseCachedRepository implements OsGroupRep
'relationships' => $relationships
]
])));
return Cache::remember($cacheKey, $this->cacheTime, function () use ($id, $relationships,$withCount,$withSum) {
return $this->osGroupRepository->findWithRelationships($id, $relationships,$withCount,$withSum);
return Cache::remember($cacheKey, $this->cacheTime, function () use ($id, $relationships, $withCount, $withSum) {
return $this->osGroupRepository->findWithRelationships($id, $relationships, $withCount, $withSum);
});
}
}