43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\Group;
|
|
|
|
use App\Repositories\BaseCachedRepository;
|
|
use App\Support\Cache\CacheKey;
|
|
|
|
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 = CacheKey::build($this->getModuleName(), 'product', ['group_id' => $group_id, 'type_id' => $type_id]);
|
|
return $this->cache->remember($cacheKey, 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 = ['*'])
|
|
{
|
|
return $this->rememberFilter(
|
|
compact('data', 'relationships', 'withCount', 'select'),
|
|
fn() => $this->groupRepository->filter($data, $relationships, $withCount, $select)
|
|
);
|
|
}
|
|
|
|
public function findBySlugWithProduct(string $slug)
|
|
{
|
|
return $this->model->where('slug', $slug)->with(['hostings', 'vps'])->first();
|
|
}
|
|
}
|