49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
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<int|string, string>|array<string, string>
|
|
*/
|
|
public function options(): Collection|array
|
|
{
|
|
/** @var Collection<int|string, string> */
|
|
$options = CacheRepository::make(
|
|
name: static::$cacheName.'_options',
|
|
value: fn () => $this->query->get(['id', 'name', 'bab'])->mapWithKeys(fn ($item) => [
|
|
$item->id => $item->name.' - '.$item->bab,
|
|
]),
|
|
);
|
|
|
|
return $options;
|
|
}
|
|
}
|