Update source into github
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Invoice;
|
||||
|
||||
use App\Repositories\BaseCachedRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class InvoiceCachedRepository extends BaseCachedRepository implements InvoiceRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
public InvoiceRepository $invoiceRepository
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
public function getModel()
|
||||
{
|
||||
return $this->invoiceRepository->getModel();
|
||||
}
|
||||
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->invoiceRepository->filter($data, $relationships, $withCount, $select);
|
||||
});
|
||||
}
|
||||
public function get_billing_year(int $year = 0)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'get_billing_year' => [
|
||||
'year' => $year
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($year) {
|
||||
return $this->invoiceRepository->get_billing_year($year);
|
||||
});
|
||||
}
|
||||
public function get_billing_month(int $month = 0)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'get_billing_month' => [
|
||||
'month' => $month
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($month) {
|
||||
return $this->invoiceRepository->get_billing_month($month);
|
||||
});
|
||||
}
|
||||
public function get_billing_day(int|string $day = '')
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'get_billing_day' => [
|
||||
'day' => $day
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($day) {
|
||||
return $this->invoiceRepository->get_billing_day($day);
|
||||
});
|
||||
}
|
||||
public function findWithRelationships(int $id = 0, array $relationships = [],array $withCount = [], array $withSum = [])
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'findWithRelationships' => [
|
||||
'id' => $id,
|
||||
'relationships' => $relationships,
|
||||
'withCount' => $withCount,
|
||||
'withSum' => $withSum
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($id, $relationships,$withCount,$withSum) {
|
||||
return $this->invoiceRepository->findWithRelationships($id, $relationships,$withCount,$withSum);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user