Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
soulaimaneyahya committed Mar 1, 2024
1 parent 82da2e8 commit d54b726
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 52 deletions.
5 changes: 0 additions & 5 deletions src/Providers/QueryFiltersServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

class QueryFiltersServiceProvider extends ServiceProvider
{
public function boot(): void
{
//
}

public function register(): void
{
$this->app->bind(QueryFiltersRepositoryInterface::class, function () {
Expand Down
18 changes: 7 additions & 11 deletions src/Repositories/QueryFiltersRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,31 @@
namespace Multividas\QueryFilters\Repositories;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Http\Resources\Json\JsonResource;
use Multividas\ApiResponser\Traits\ApiResponser;
use Multividas\QueryFilters\Services\Caching\CacheService;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Multividas\QueryFilters\Interfaces\QueryFiltersRepositoryInterface;

class QueryFiltersRepository implements QueryFiltersRepositoryInterface
{
use ApiResponser;

private string $url;
private string $fullUrl;
private string|array|null $queryParams;
private string $queryString;
private string|array|null $queryParams;

/**
* Method __construct
*
* @param private CacheService $cacheService
*
* @return void
*/
public function __construct(
private CacheService $cacheService
) {
public function __construct()
{
$this->url = request()->url();

$this->queryParams = request()->query();
ksort($this->queryParams);

$this->queryString = http_build_query($this->queryParams);

$this->fullUrl = "{$this->url}?{$this->queryString}";
Expand Down Expand Up @@ -133,7 +129,7 @@ public function sortData(
public function cacheData(
Collection|EloquentCollection|JsonResource $collection
): Collection|EloquentCollection|JsonResource {
return $this->cacheService->remember($this->fullUrl, now()->addSeconds(60), function () use ($collection) {
return Cache::remember($this->fullUrl, now()->addSeconds(60), function () use ($collection) {
return $collection;
});
}
Expand Down
Empty file removed src/Services/.gitkeep
Empty file.
36 changes: 0 additions & 36 deletions src/Services/Caching/CacheService.php

This file was deleted.

0 comments on commit d54b726

Please sign in to comment.