Files
online.tbbank.gov.tm-larave…/app/Repos/Branch/BranchRepo.php
2024-09-01 18:40:53 +05:00

66 lines
1.1 KiB
PHP

<?php
namespace App\Repos\Branch;
use App\Models\Branch\Branch;
use Illuminate\Support\Collection;
class BranchRepo
{
/**
* Model
*/
protected mixed $model;
/**
* Query
*/
protected mixed $query;
/**
* New Branch Repo
*/
public function __construct()
{
$this->model = Branch::class;
$this->query = $this->model::query();
$this->queryActive();
}
/**
* Query active records
*/
public function queryActive(): self
{
$this->query->where('active', true);
return $this;
}
/**
* "Make" static sugar
*/
public static function make(): self
{
return new self;
}
/**
* Query
*/
public function query(): mixed
{
return $this->query;
}
/**
* Branch values
*
* @return \Illuminate\Support\Collection<int, string>|array<int, string>
*/
public static function values(): Collection|array
{
return static::make()->query()->pluck('name', 'id');
}
}