update deploy
This commit is contained in:
42
app/Repositories/Eloquent/HeroSlideRepository.php
Normal file
42
app/Repositories/Eloquent/HeroSlideRepository.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Eloquent;
|
||||
|
||||
use App\Models\HeroSlide;
|
||||
use App\Repositories\Contracts\HeroSlideRepositoryInterface;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
/**
|
||||
* @extends BaseRepository<HeroSlide>
|
||||
*/
|
||||
class HeroSlideRepository extends BaseRepository implements HeroSlideRepositoryInterface
|
||||
{
|
||||
public function __construct(HeroSlide $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $filters
|
||||
* @return LengthAwarePaginator<int, HeroSlide>
|
||||
*/
|
||||
public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->orderBy('order_index')
|
||||
->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, HeroSlide>
|
||||
*/
|
||||
public function active(): Collection
|
||||
{
|
||||
return Cache::remember('hero_slides', 3600, fn () => $this->model->newQuery()
|
||||
->where('is_active', true)
|
||||
->orderBy('order_index')
|
||||
->get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user