61 lines
970 B
PHP
61 lines
970 B
PHP
<?php
|
|
|
|
namespace App\Repos\Branch;
|
|
|
|
use App\Models\Branch\Branch;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class BranchRepo
|
|
{
|
|
/**
|
|
* Model
|
|
*
|
|
* @var App\Models\Branch\Branch
|
|
*/
|
|
protected $model;
|
|
|
|
/**
|
|
* 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()
|
|
{
|
|
return $this->query;
|
|
}
|
|
|
|
/**
|
|
* Branch values
|
|
*/
|
|
public static function values(): Collection|array
|
|
{
|
|
return static::make()->query()->pluck('name', 'id');
|
|
}
|
|
}
|