Code Duplication    Length = 48-59 lines in 2 locations

src/Repositories/Widget/WidgetCacheRepository.php 1 location

@@ 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
}

src/Repositories/Navigation/CacheRepository.php 1 location

@@ 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