Files
telekeci/app/Modules/Bank/Repositories/BankRepository.php

46 lines
1020 B
PHP

<?php
namespace App\Modules\Bank\Repositories;
use App\Modules\AppHelpers\Repositories\CacheRepository;
use App\Modules\Bank\Models\Bank;
use App\Modules\Makeable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
class BankRepository
{
use Makeable;
/** @var Builder<Bank> */
protected Builder $query;
/**
* Cache name
*/
protected static string $cacheName = 'BANK_REPOSITORY';
/**
* Bank repository
*/
public function __construct()
{
$this->query = Bank::query();
}
/**
* Return available options
*
* @return Collection<array-key, mixed>|array<string, string>
*/
public function options(): Collection|array
{
return CacheRepository::make(
name: static::$cacheName.'_options',
value: fn () => $this->query->get(['id', 'name', 'bab'])->mapWithKeys(fn ($item) => [
$item->id => $item->name.' - '.$item->bab,
]),
);
}
}