43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\Eloquent;
|
|
|
|
use App\Models\GuideCard;
|
|
use App\Repositories\Contracts\GuideCardRepositoryInterface;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
/**
|
|
* @extends BaseRepository<GuideCard>
|
|
*/
|
|
class GuideCardRepository extends BaseRepository implements GuideCardRepositoryInterface
|
|
{
|
|
public function __construct(GuideCard $model)
|
|
{
|
|
parent::__construct($model);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $filters
|
|
* @return LengthAwarePaginator<int, GuideCard>
|
|
*/
|
|
public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator
|
|
{
|
|
return $this->model->newQuery()
|
|
->orderBy('order_index')
|
|
->paginate($perPage);
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, GuideCard>
|
|
*/
|
|
public function active(): Collection
|
|
{
|
|
return Cache::remember('guide_cards', 3600, fn () => $this->model->newQuery()
|
|
->where('is_active', true)
|
|
->orderBy('order_index')
|
|
->get());
|
|
}
|
|
}
|