Update source into github

This commit is contained in:
pbao9
2025-07-24 16:18:27 +07:00
parent 41419358dd
commit 69851ac7bc
2642 changed files with 284095 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
namespace App\Repositories\Addon;
use App\Repositories\BaseCachedRepository;
use Illuminate\Support\Facades\Cache;
class AddonCachedRepository extends BaseCachedRepository implements AddonRepositoryInterface
{
public function __construct(
public AddonRepository $addonRepository
) {
parent::__construct();
}
public function getModel()
{
return $this->addonRepository->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->addonRepository->filter($data, $relationships, $withCount, $select);
});
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Repositories\Addon;
use App\Models\Addon;
use App\Repositories\BaseRepository;
class AddonRepository extends BaseRepository implements AddonRepositoryInterface
{
public function getModel()
{
return Addon::class;
}
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
{
$model = $this->model->with($relationships)->select($select);
if (count($withCount) > 0) {
$model = $model->withCount($withCount);
}
if(isset($data['page'])) {
return $model->paginate(15);
}
return $model->get();
}
}
@@ -0,0 +1,9 @@
<?php
namespace App\Repositories\Addon;
use App\Repositories\BaseRepositoryInterface;
interface AddonRepositoryInterface extends BaseRepositoryInterface{
public function filter(array $data = [],array $relationships = [],array $withCount = [],array $select = ['*']);
}