Update source into github
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Group;
|
||||
|
||||
use App\Repositories\BaseCachedRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class GroupCachedRepository extends BaseCachedRepository implements GroupRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
public GroupRepository $groupRepository
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getModel()
|
||||
{
|
||||
return $this->groupRepository->getModel();
|
||||
}
|
||||
|
||||
public function getProduct(int $group_id = 0, int $type_id = 0)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'type_id' => $type_id,
|
||||
'group_id' => $group_id
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($type_id, $group_id) {
|
||||
return $this->groupRepository->getProduct($group_id, $type_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filterItem' => [
|
||||
'data' => $data,
|
||||
'relationships' => $relationships,
|
||||
'select' => $select,
|
||||
'withCount' => $withCount
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($data, $relationships, $select, $withCount) {
|
||||
return $this->groupRepository->filter($data, $relationships, $withCount, $select);
|
||||
});
|
||||
}
|
||||
|
||||
public function findBySlugWithProduct(string $slug)
|
||||
{
|
||||
return $this->model->where('slug', $slug)->with(['hostings', 'vps'])->first();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user