| @@ 7-54 (lines=48) @@ | ||
| 4 | ||
| 5 | use Illuminate\Contracts\Cache\Repository as Cache; |
|
| 6 | ||
| 7 | class WidgetCacheRepository implements WidgetRepository |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var \Yajra\CMS\Repositories\Widget\WidgetRepository |
|
| 11 | */ |
|
| 12 | protected $repository; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var \Illuminate\Contracts\Cache\Repository |
|
| 16 | */ |
|
| 17 | protected $cache; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * WidgetCacheRepository constructor. |
|
| 21 | * |
|
| 22 | * @param \Yajra\CMS\Repositories\Widget\WidgetRepository $repository |
|
| 23 | * @param \Illuminate\Contracts\Cache\Repository $cache |
|
| 24 | */ |
|
| 25 | public function __construct(WidgetRepository $repository, Cache $cache) |
|
| 26 | { |
|
| 27 | $this->repository = $repository; |
|
| 28 | $this->cache = $cache; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Get all widgets. |
|
| 33 | * |
|
| 34 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
|
| 35 | */ |
|
| 36 | public function all() |
|
| 37 | { |
|
| 38 | return $this->cache->rememberForever('widgets.all', function () { |
|
| 39 | return $this->repository->all(); |
|
| 40 | }); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Get all published widgets. |
|
| 45 | * |
|
| 46 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
|
| 47 | */ |
|
| 48 | public function getPublished() |
|
| 49 | { |
|
| 50 | return $this->cache->rememberForever('widgets.published', function () { |
|
| 51 | return $this->repository->getPublished(); |
|
| 52 | }); |
|
| 53 | } |
|
| 54 | } |
|
| @@ 7-65 (lines=59) @@ | ||
| 4 | ||
| 5 | use Illuminate\Contracts\Cache\Repository as Cache; |
|
| 6 | ||
| 7 | class CacheRepository implements Repository |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var \Yajra\CMS\Repositories\Navigation\Repository |
|
| 11 | */ |
|
| 12 | protected $repository; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var \Illuminate\Contracts\Cache\Repository |
|
| 16 | */ |
|
| 17 | protected $cache; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * NavigationRepository constructor. |
|
| 21 | * |
|
| 22 | * @param \Yajra\CMS\Repositories\Navigation\Repository $repository |
|
| 23 | * @param \Illuminate\Contracts\Cache\Repository $cache |
|
| 24 | */ |
|
| 25 | public function __construct(Repository $repository, Cache $cache) |
|
| 26 | { |
|
| 27 | $this->repository = $repository; |
|
| 28 | $this->cache = $cache; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Get all navigation. |
|
| 33 | * |
|
| 34 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
|
| 35 | */ |
|
| 36 | public function all() |
|
| 37 | { |
|
| 38 | return $this->cache->rememberForever('navigation.all', function () { |
|
| 39 | return $this->repository->all(); |
|
| 40 | }); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Get all published navigation. |
|
| 45 | * |
|
| 46 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
|
| 47 | */ |
|
| 48 | public function getPublished() |
|
| 49 | { |
|
| 50 | return $this->cache->rememberForever('navigation.published', function () { |
|
| 51 | return $this->repository->getPublished(); |
|
| 52 | }); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Find or fail a navigation. |
|
| 57 | * |
|
| 58 | * @param int $id |
|
| 59 | * @return \Yajra\CMS\Entities\Navigation |
|
| 60 | */ |
|
| 61 | public function findOrFail($id) |
|
| 62 | { |
|
| 63 | return $this->repository->findOrFail($id); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 7-73 (lines=67) @@ | ||
| 4 | ||
| 5 | use Illuminate\Contracts\Cache\Repository as Cache; |
|
| 6 | ||
| 7 | class FileAssetCacheRepository implements FileAssetRepository |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var \Yajra\CMS\Repositories\FileAsset\FileAssetRepository |
|
| 11 | */ |
|
| 12 | private $repository; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var \Illuminate\Contracts\Cache\Repository |
|
| 16 | */ |
|
| 17 | private $cache; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * FileAssetCacheRepository constructor. |
|
| 21 | * |
|
| 22 | * @param \Yajra\CMS\Repositories\FileAsset\FileAssetRepository $repository |
|
| 23 | * @param \Illuminate\Contracts\Cache\Repository $cache |
|
| 24 | */ |
|
| 25 | public function __construct(FileAssetRepository $repository, Cache $cache) |
|
| 26 | { |
|
| 27 | $this->repository = $repository; |
|
| 28 | $this->cache = $cache; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Get all file assets. |
|
| 33 | * |
|
| 34 | * @return \Illuminate\Database\Eloquent\Collection|static[] |
|
| 35 | */ |
|
| 36 | public function all() |
|
| 37 | { |
|
| 38 | return $this->cache->rememberForever('fileAssets.all', function () { |
|
| 39 | return $this->repository->all(); |
|
| 40 | }); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Register admin required assets. |
|
| 45 | */ |
|
| 46 | public function registerAdminRequireAssets() |
|
| 47 | { |
|
| 48 | return $this->repository->registerAdminRequireAssets(); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Get file asset by name. |
|
| 53 | * |
|
| 54 | * @param string $name |
|
| 55 | * @param null $category |
|
| 56 | * @return \Yajra\CMS\Repositories\FileAsset\FileAsset |
|
| 57 | */ |
|
| 58 | public function getByName($name, $category = null) |
|
| 59 | { |
|
| 60 | return $this->repository->getByName($name, $category); |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Add site asset. |
|
| 65 | * |
|
| 66 | * @param string $type |
|
| 67 | * @return \Roumen\Asset\Asset; |
|
| 68 | */ |
|
| 69 | public function addAsset($type) |
|
| 70 | { |
|
| 71 | return $this->repository->addAsset($type); |
|
| 72 | } |
|
| 73 | } |
|