feat: Remove the entire frontend customer portal and its associated controllers, while updating customer repositories and adding a cache table migration.
This commit is contained in:
@@ -16,19 +16,32 @@ class CustomerCachedRepository extends BaseCachedRepository implements CustomerR
|
||||
{
|
||||
return $this->customerRepository->getModel();
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
) {
|
||||
if (
|
||||
$returnQuery ||
|
||||
!empty($data['paginate'])
|
||||
) {
|
||||
return $this->customerRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filterItem' => [
|
||||
'data' => $data,
|
||||
'relationships' => $relationships,
|
||||
'select' => $select,
|
||||
'withCount' => $withCount
|
||||
]
|
||||
'filter' => compact('data', 'relationships', 'withCount', 'select')
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($data, $relationships, $select, $withCount) {
|
||||
return $this->customerRepository->filter($data, $relationships, $withCount, $select);
|
||||
});
|
||||
|
||||
return Cache::remember(
|
||||
$cacheKey,
|
||||
$this->cacheTime,
|
||||
fn() =>
|
||||
$this->customerRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
);
|
||||
}
|
||||
public function findWithRelationships(int $id = 0, array $relationships = [], array $withCount = [], array $withSum = [])
|
||||
{
|
||||
|
||||
@@ -11,14 +11,18 @@ class CustomerRepository extends BaseRepository implements CustomerRepositoryInt
|
||||
{
|
||||
return Customer::class;
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
) {
|
||||
$model = $this->model->with($relationships)->select($select);
|
||||
if (isset($data['name']) && ! empty($data['name'])) {
|
||||
$model = $model->where(function ($query) use ($data) {
|
||||
$name = trim($data['name']);
|
||||
$query->where("firstname", "LIKE", "%$name%");
|
||||
$query->orWhere("lastname", "LIKE", "%$name%");
|
||||
$query->where("fullname", "LIKE", "%$name%");
|
||||
$query->orWhere("company", "LIKE", "%$name%");
|
||||
});
|
||||
}
|
||||
@@ -59,6 +63,9 @@ class CustomerRepository extends BaseRepository implements CustomerRepositoryInt
|
||||
if (count($withCount) > 0) {
|
||||
$model = $model->withCount($withCount);
|
||||
}
|
||||
if ($returnQuery) {
|
||||
return $model;
|
||||
}
|
||||
if (isset($data['page'])) {
|
||||
return $model->paginate(15);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,13 @@ use App\Repositories\BaseRepositoryInterface;
|
||||
|
||||
interface CustomerRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
public function filter(array $data = [],array $relationships = [],array $withCount = [],array $select = ['*']);
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
);
|
||||
public function findWithRelationships(int $id = 0, array $relationships = [],array $withCount = [], array $withSum = []);
|
||||
public function findBy(string $key = '',string $value = '');
|
||||
}
|
||||
Reference in New Issue
Block a user