-
Notifications
You must be signed in to change notification settings - Fork 1
Cacheable
Gilberto Junior edited this page Dec 5, 2019
·
3 revisions
Avaliable for classes that extends CodeHappy\DataLayer\Repository
.
Add the trait CodeHappy\DataLayer\Traits\Cacheable
into the repository:
<?php
namespace App\Repositories;
use CodeHappy\DataLayer\Repository;
use CodeHappy\DataLayer\Traits\Cacheable;
use App\Repositories\CachingUserRepository;
class UserRepository extends Repository
{
use Cacheable; // Add Trait
protected $cachingRepository = CachingUserRepository::class; // Declare your Caching Repository class name
}
To call the instance of CodeHappy\DataLayer\CachingRepository
.
public function cached(): CachingRepository;
PHP's way:
$productRepository->cached()
->isEqualTo('store_id', 123456)
->isBetween('order_date', '2019-11-29 00:00:00', '2019-11-29 23:59:59')
->fetchFirst();
by c0dehappy