Compare commits
18 Commits
2.2.4
...
2a06507876
Author | SHA1 | Date | |
---|---|---|---|
2a06507876 | |||
e4cec2e2f2 | |||
faf615e79d | |||
8a03d9e675 | |||
b8409182d7 | |||
100df73916 | |||
e576ef5054 | |||
5c1f424c76 | |||
b19654bc70 | |||
fe67519682 | |||
0af6be2c8e | |||
0a9bed1735 | |||
ba3c70a70e | |||
422d9a6dbd | |||
bc006f3e01 | |||
23c56f9511 | |||
4ccc38ffac | |||
ef1603bc4b |
@ -78,7 +78,7 @@ abstract class Model implements ModelInterface
|
||||
if ($method->getName() === 'getRepository') {
|
||||
continue;
|
||||
}
|
||||
$p = strtolower(str_replace('get', '', $method->getName()));
|
||||
$p = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', str_replace('get', '', $method->getName())));
|
||||
if (!isset($this->{$p})) {
|
||||
continue;
|
||||
}
|
||||
|
@ -18,62 +18,83 @@ abstract class Repository implements RepositoryInterface
|
||||
}
|
||||
|
||||
protected Connection $connection;
|
||||
public function setConnection(Connection $connection): Repository
|
||||
{
|
||||
$this->connection = $connection;
|
||||
return $this;
|
||||
}
|
||||
protected QueryBuilder $builder;
|
||||
protected Factory $factory;
|
||||
protected string $model;
|
||||
protected string $table;
|
||||
protected array $columns;
|
||||
protected array $required_columns;
|
||||
protected array $optional_columns;
|
||||
protected array $properties;
|
||||
|
||||
public function getConnection(): Connection
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
protected QueryBuilder $builder;
|
||||
public function setQueryBuilder(QueryBuilder $builder): RepositoryInterface
|
||||
{
|
||||
$this->builder = $builder;
|
||||
return $this;
|
||||
}
|
||||
public function getQueryBuilder(): QueryBuilder
|
||||
{
|
||||
return $this->builder;
|
||||
}
|
||||
protected Factory $factory;
|
||||
public function setFactory(Factory $factory): RepositoryInterface
|
||||
{
|
||||
$this->factory = $factory;
|
||||
return $this;
|
||||
}
|
||||
public function getFactory(): Factory
|
||||
{
|
||||
return $this->factory;
|
||||
}
|
||||
protected string $model;
|
||||
public function setModel(string $model_class): RepositoryInterface
|
||||
{
|
||||
$this->model = $model_class;
|
||||
return $this;
|
||||
}
|
||||
public function getModel(): string
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
public function getNewModel(): Model
|
||||
public function getTable(): string
|
||||
{
|
||||
$class = $this->getModel();
|
||||
return (new $class())
|
||||
->setRepository($this);
|
||||
return $this->table;
|
||||
}
|
||||
public function getColumns(): array
|
||||
{
|
||||
return $this->columns ?? array_merge($this->getRequiredColumns(), $this->getOptionalColumns());
|
||||
}
|
||||
public function getRequiredColumns(): array
|
||||
{
|
||||
if (isset($this->optional_columns) and !isset($this->required_columns)) {
|
||||
return array_diff($this->getColumns(), $this->getOptionalColumns());
|
||||
}
|
||||
return $this->required_columns ?? $this->getColumns();
|
||||
}
|
||||
public function getOptionalColumns(): array
|
||||
{
|
||||
if (isset($this->required_columns) and !isset($this->optional_columns)) {
|
||||
return array_diff($this->getColumns(), $this->getRequiredColumns());
|
||||
}
|
||||
return $this->optional_columns ?? [];
|
||||
}
|
||||
public function getProperties(): array
|
||||
{
|
||||
return $this->properties ?? $this->getColumns();
|
||||
}
|
||||
|
||||
public function setConnection(Connection $connection): Repository
|
||||
{
|
||||
$this->connection = $connection;
|
||||
return $this;
|
||||
}
|
||||
public function setQueryBuilder(QueryBuilder $builder): RepositoryInterface
|
||||
{
|
||||
$this->builder = $builder;
|
||||
return $this;
|
||||
}
|
||||
public function setFactory(Factory $factory): RepositoryInterface
|
||||
{
|
||||
$this->factory = $factory;
|
||||
return $this;
|
||||
}
|
||||
public function setModel(string $model_class): RepositoryInterface
|
||||
{
|
||||
$this->model = $model_class;
|
||||
return $this;
|
||||
}
|
||||
protected string $table;
|
||||
public function setTable(string $table): RepositoryInterface
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
protected array $columns;
|
||||
public function setColumns(array $columns): RepositoryInterface
|
||||
{
|
||||
foreach ($columns as $column) {
|
||||
@ -81,59 +102,58 @@ abstract class Repository implements RepositoryInterface
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function setRequiredColumns(array $columns): RepositoryInterface
|
||||
{
|
||||
foreach ($columns as $item) {
|
||||
$this->addRequiredColumn($item);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function setOptionalColumns(array $columns): RepositoryInterface
|
||||
{
|
||||
foreach ($columns as $item) {
|
||||
$this->addOptionalColumn($item);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function setProperties(array $properties): RepositoryInterface
|
||||
{
|
||||
foreach ($properties as $property) {
|
||||
$this->addProperty($property);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addColumn(string $column): RepositoryInterface
|
||||
{
|
||||
$this->columns []= $column;
|
||||
return $this;
|
||||
}
|
||||
public function getColumns(): array
|
||||
public function addRequiredColumn(string $column): RepositoryInterface
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
protected array $required;
|
||||
public function setRequired(array $columns): RepositoryInterface
|
||||
{
|
||||
foreach ($columns as $item) {
|
||||
$this->addRequired($item);
|
||||
}
|
||||
$this->required_columns []= $column;
|
||||
return $this;
|
||||
}
|
||||
public function addRequired(string $column): RepositoryInterface
|
||||
public function addOptionalColumn(string $column): RepositoryInterface
|
||||
{
|
||||
$this->required []= $column;
|
||||
$this->optional_columns []= $column;
|
||||
return $this;
|
||||
}
|
||||
public function getRequired(): array
|
||||
public function addProperty(string $property): RepositoryInterface
|
||||
{
|
||||
if (isset($this->optional) and !isset($this->required)) {
|
||||
return array_diff($this->getColumns(), $this->getOptional());
|
||||
}
|
||||
return $this->required ?? $this->getColumns();
|
||||
}
|
||||
protected array $optional;
|
||||
public function setOptional(array $columns): RepositoryInterface
|
||||
{
|
||||
foreach ($columns as $item) {
|
||||
$this->addColumn($item);
|
||||
}
|
||||
$this->properties []= $property;
|
||||
return $this;
|
||||
}
|
||||
public function addOptional(string $column): RepositoryInterface
|
||||
{
|
||||
$this->optional []= $column;
|
||||
return $this;
|
||||
}
|
||||
public function getOptional(): array
|
||||
{
|
||||
if (isset($this->required) and !isset($this->optional)) {
|
||||
return array_diff($this->getColumns(), $this->getRequired());
|
||||
}
|
||||
return $this->optional ?? [];
|
||||
}
|
||||
|
||||
public function getMethod(string $column, bool $get = true): string
|
||||
public function getNewModel(): Model
|
||||
{
|
||||
$m = str_replace(' ', '', ucwords(str_replace('_', ' ', $column)));
|
||||
$class = $this->getModel();
|
||||
return (new $class())
|
||||
->setRepository($this);
|
||||
}
|
||||
public function getMethod(string $property, bool $get = true): string
|
||||
{
|
||||
$m = str_replace(' ', '', ucwords(str_replace('_', ' ', $property)));
|
||||
if ($get) {
|
||||
return "get{$m}";
|
||||
}
|
||||
@ -147,36 +167,105 @@ abstract class Repository implements RepositoryInterface
|
||||
}
|
||||
return strtolower(implode('_', $parts));
|
||||
}
|
||||
public function fillData(Model $model, array $data): Model
|
||||
|
||||
protected function compareProp(string $property, ?array $data = null): bool
|
||||
{
|
||||
foreach ($this->getRequired() as $column) {
|
||||
$m = $this->getMethod($column, false);
|
||||
$model->{$m}($data[$column]);
|
||||
if ($data === null) {
|
||||
return in_array($property, $this->getRequiredColumns());
|
||||
}
|
||||
foreach ($this->getOptional() as $column) {
|
||||
if (!isset($data[$column])) {
|
||||
continue;
|
||||
return in_array($property, $this->getOptionalColumns()) and key_exists($property, $data);
|
||||
}
|
||||
protected function compareProperty(string $property, ?array $data = null, ?string &$tmp_property = null): bool
|
||||
{
|
||||
$tmp_property = $property;
|
||||
if ($this->compareProp($tmp_property, $data)) {
|
||||
return true;
|
||||
}
|
||||
$tmp_property = "{$property}_id";
|
||||
return $this->compareProp($tmp_property, $data);
|
||||
}
|
||||
protected function validateDefaultProperty(mixed $value): bool
|
||||
{
|
||||
$defaults = [
|
||||
0,
|
||||
'',
|
||||
null
|
||||
];
|
||||
return in_array($value, $defaults);
|
||||
}
|
||||
protected function editModel(Model $model, string $getter, string $setter, mixed $value, bool $optional = false): Model
|
||||
{
|
||||
try {
|
||||
$val = $model->{$getter}();
|
||||
if ($optional and $this->validateDefaultProperty($val)) {
|
||||
$model->{$setter}($value);
|
||||
}
|
||||
$m = $this->getMethod($column, false);
|
||||
$model->{$m}($data[$column]);
|
||||
} catch (\Error|\Exception $e) {
|
||||
$model->{$setter}($value);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
public function mapArray(Model $model, array $data): array
|
||||
public function mapModel(Model $model, array $data): Model
|
||||
{
|
||||
foreach ($this->getColumns() as $column) {
|
||||
if (isset($data[$column])) {
|
||||
/**
|
||||
* Default Model map
|
||||
* It is assumed that the Model properties are named like the table columns
|
||||
*/
|
||||
foreach ($this->getProperties() as $property) {
|
||||
$getter = $this->getMethod($property);
|
||||
$setter = $this->getMethod($property, false);
|
||||
if ($this->compareProperty($property, tmp_property: $tmp)) {
|
||||
$model = $this->editModel($model, $getter, $setter, $data[$tmp]);
|
||||
continue;
|
||||
}
|
||||
if (!method_exists($model, $setter)) {
|
||||
continue;
|
||||
}
|
||||
if ($this->compareProperty($property, $data, $tmp)) {
|
||||
$model = $this->editModel($model, $getter, $setter, $data[$tmp], true);
|
||||
}
|
||||
try {
|
||||
$value = $model->{$getter}();
|
||||
if ($this->validateDefaultProperty($value)) {
|
||||
error_log("Notice: {$property} has default value in " . get_called_class());
|
||||
}
|
||||
} catch (\Error | \Exception $e) {
|
||||
error_log("Warning: Missing {$property} in data for " . get_called_class() . "::fillData");
|
||||
}
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
public function mapTable(Model $model, array $data): array
|
||||
{
|
||||
/**
|
||||
* Default table map
|
||||
* It is assumed that the table columns are named the same as the Model properties
|
||||
*/
|
||||
foreach ($this->getRequiredColumns() as $column) {
|
||||
$m = $this->getMethod($column);
|
||||
$val = $model->{$m}();
|
||||
$data[$column] = $val;
|
||||
if (!method_exists($model, $m)) {
|
||||
error_log("Warning: Missing getter for {$column} in " . get_called_class() . "::mapArray");
|
||||
continue;
|
||||
}
|
||||
if (!isset($data[$column])) {
|
||||
$data[$column] = $model->{$m}();
|
||||
}
|
||||
}
|
||||
foreach ($this->getOptionalColumns() as $column) {
|
||||
$m = $this->getMethod($column);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($data[$column])) {
|
||||
$data[$column] = $model->{$m}();
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function load(array $data): Model
|
||||
{
|
||||
return $this->fillData($this->getNewModel()
|
||||
return $this->mapModel($this->getNewModel()
|
||||
->setId($data['id']), $data);
|
||||
}
|
||||
public function save(Model $model): void
|
||||
@ -188,17 +277,17 @@ abstract class Repository implements RepositoryInterface
|
||||
$this->update($model);
|
||||
return;
|
||||
}
|
||||
$values = $this->mapArray($model, []);
|
||||
$values = array_replace(array_flip($this->getColumns()), $this->mapTable($model, []));
|
||||
$cols = array_fill(0, count($values), '?');
|
||||
$query = $this->getQueryBuilder()->insert($this->getTable())->columns($this->getColumns())->values($cols);
|
||||
$this->getConnection()->execute($query, $values);
|
||||
$this->getConnection()->execute($query, array_values($values));
|
||||
}
|
||||
public function update(Model $model): void
|
||||
{
|
||||
if (!$model->isDirty() and !$model->isNew()) {
|
||||
return;
|
||||
}
|
||||
$values = $this->mapArray($model, []);
|
||||
$values = $this->mapTable($model, []);
|
||||
$cols = array_map(function($column) {
|
||||
return "{$column} = ?";
|
||||
}, $values);
|
||||
@ -209,7 +298,7 @@ abstract class Repository implements RepositoryInterface
|
||||
}
|
||||
public function create(array $data): Model
|
||||
{
|
||||
return $this->fillData($this->getNewModel()
|
||||
return $this->mapModel($this->getNewModel()
|
||||
->setNew(), $data);
|
||||
}
|
||||
public function edit(Model $model, array $data): Model
|
||||
@ -217,6 +306,9 @@ abstract class Repository implements RepositoryInterface
|
||||
foreach ($this->getColumns() as $col) {
|
||||
if (isset($data[$col])) {
|
||||
$m = $this->getMethod($col, false);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
$model->{$m}($data[$col]);
|
||||
}
|
||||
}
|
||||
@ -235,7 +327,7 @@ abstract class Repository implements RepositoryInterface
|
||||
->from($this->getTable())
|
||||
->where(['id = ?'])
|
||||
->limit(1);
|
||||
return $this->load($this->getConnection()->execute($query, [$id])->getAsArray()[0]);
|
||||
return $this->load($this->getConnection()->execute($query, [$id])->getFirstAsArray());
|
||||
}
|
||||
public function fetchAll(): array
|
||||
{
|
||||
|
@ -1,11 +1,48 @@
|
||||
<?php
|
||||
namespace ProVM\Concept\Model;
|
||||
|
||||
use ProVM\Concept\Model;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
interface Factory
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return Factory
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container): Factory;
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getContainer(): ContainerInterface;
|
||||
|
||||
/**
|
||||
* Get Repository by class
|
||||
* @param string $repository_class
|
||||
* @return Repository
|
||||
*/
|
||||
public function get(string $repository_class): Repository;
|
||||
|
||||
/**
|
||||
* Get Repository by Model class
|
||||
* @param string $model_class
|
||||
* @return Repository
|
||||
*/
|
||||
public function getByModel(string $model_class): Repository;
|
||||
|
||||
/**
|
||||
* Fetch Model by Id
|
||||
* @param string $model_class
|
||||
* @param int $id
|
||||
* @return Model
|
||||
*/
|
||||
public function fetchById(string $model_class, int $id): Model;
|
||||
|
||||
/**
|
||||
* Fetch all Models
|
||||
* @param string $model_class
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll(string $model_class): array;
|
||||
}
|
||||
|
@ -7,37 +7,212 @@ use ProVM\Concept\Model;
|
||||
|
||||
interface Repository
|
||||
{
|
||||
public function setConnection(Connection $connection): Repository;
|
||||
/**
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection(): Connection;
|
||||
public function setQueryBuilder(QueryBuilder $builder): Repository;
|
||||
/**
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function getQueryBuilder(): QueryBuilder;
|
||||
public function setFactory(Factory $factory): Repository;
|
||||
/**
|
||||
* @return Factory
|
||||
*/
|
||||
public function getFactory(): Factory;
|
||||
public function setModel(string $model_class): Repository;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string;
|
||||
public function getNewModel(): Model;
|
||||
public function setup(): Repository;
|
||||
public function setTable(string $table): Repository;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTable(): string;
|
||||
public function setColumns(array $columns): Repository;
|
||||
public function addColumn(string $column): Repository;
|
||||
/**
|
||||
* Get table columns
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns(): array;
|
||||
public function setRequired(array $columns): Repository;
|
||||
public function addRequired(string $column): Repository;
|
||||
public function getRequired(): array;
|
||||
public function setOptional(array $columns): Repository;
|
||||
public function addOptional(string $column): Repository;
|
||||
public function getOptional(): array;
|
||||
public function getMethod(string $column, bool $get = true): string;
|
||||
/**
|
||||
* Get required columns
|
||||
* @return array
|
||||
*/
|
||||
public function getRequiredColumns(): array;
|
||||
/**
|
||||
* Get optional columns
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionalColumns(): array;
|
||||
/**
|
||||
* Get Model properties
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties(): array;
|
||||
|
||||
/**
|
||||
* @param Connection $connection
|
||||
* @return Repository
|
||||
*/
|
||||
public function setConnection(Connection $connection): Repository;
|
||||
/**
|
||||
* @param QueryBuilder $builder
|
||||
* @return Repository
|
||||
*/
|
||||
public function setQueryBuilder(QueryBuilder $builder): Repository;
|
||||
/**
|
||||
* @param Factory $factory
|
||||
* @return Repository
|
||||
*/
|
||||
public function setFactory(Factory $factory): Repository;
|
||||
/**
|
||||
* @param string $model_class
|
||||
* @return Repository
|
||||
*/
|
||||
public function setModel(string $model_class): Repository;
|
||||
/**
|
||||
* @param string $table
|
||||
* @return Repository
|
||||
*/
|
||||
public function setTable(string $table): Repository;
|
||||
/**
|
||||
* Set columns in table
|
||||
* @param array $columns
|
||||
* @return Repository
|
||||
*/
|
||||
public function setColumns(array $columns): Repository;
|
||||
/**
|
||||
* Set required columns
|
||||
* Optional
|
||||
* @param array $columns
|
||||
* @return Repository
|
||||
*/
|
||||
public function setRequiredColumns(array $columns): Repository;
|
||||
/**
|
||||
* Set optional columns
|
||||
* @param array $columns
|
||||
* @return Repository
|
||||
*/
|
||||
public function setOptionalColumns(array $columns): Repository;
|
||||
/**
|
||||
* Set Model properties
|
||||
* @param array $properties
|
||||
* @return Repository
|
||||
*/
|
||||
public function setProperties(array $properties): Repository;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @return Repository
|
||||
*/
|
||||
public function addColumn(string $column): Repository;
|
||||
/**
|
||||
* @param string $column
|
||||
* @return Repository
|
||||
*/
|
||||
public function addRequiredColumn(string $column): Repository;
|
||||
/**
|
||||
* @param string $column
|
||||
* @return Repository
|
||||
*/
|
||||
public function addOptionalColumn(string $column): Repository;
|
||||
/**
|
||||
* @param string $property
|
||||
* @param $value
|
||||
* @return Repository
|
||||
*/
|
||||
public function addProperty(string $property): Repository;
|
||||
|
||||
/**
|
||||
* Set up the Repository
|
||||
* SHOULD CALL
|
||||
* setTable
|
||||
* setColumns [setRequired, setOptional]
|
||||
* setProperties
|
||||
* setMapping
|
||||
* setModel
|
||||
* @return Repository
|
||||
*/
|
||||
public function setup(): Repository;
|
||||
|
||||
/**
|
||||
* Get clean empty Model
|
||||
* @return Model
|
||||
*/
|
||||
public function getNewModel(): Model;
|
||||
/**
|
||||
* Get Model method
|
||||
* @param string $property
|
||||
* @param bool $get
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod(string $property, bool $get = true): string;
|
||||
/**
|
||||
* @param string $method
|
||||
* @return string
|
||||
*/
|
||||
public function getProperty(string $method): string;
|
||||
public function fillData(Model $model, array $data): Model;
|
||||
public function mapArray(Model $model, array $data): array;
|
||||
|
||||
/**
|
||||
* Fill empty Model with data
|
||||
* @param Model $model
|
||||
* @param array $data
|
||||
* @return Model
|
||||
*/
|
||||
public function mapModel(Model $model, array $data): Model;
|
||||
/**
|
||||
* Fill data array with Model values. Accepts a preset data array
|
||||
* @param Model $model
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function mapTable(Model $model, array $data): array;
|
||||
|
||||
/**
|
||||
* Transform result array to Model
|
||||
* @param array $data
|
||||
* @return Model
|
||||
*/
|
||||
public function load(array $data): Model;
|
||||
/**
|
||||
* Save Model to table
|
||||
* @param Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function save(Model $model): void;
|
||||
/**
|
||||
* Update table value with Model
|
||||
* @param Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function update(Model $model): void;
|
||||
/**
|
||||
* Create new Model with data
|
||||
* @param array $data
|
||||
* @return Model
|
||||
*/
|
||||
public function create(array $data): Model;
|
||||
/**
|
||||
* Edit Model with data
|
||||
* @param Model $model
|
||||
* @param array $data
|
||||
* @return Model
|
||||
*/
|
||||
public function edit(Model $model, array $data): Model;
|
||||
/**
|
||||
* Delete Model from table
|
||||
* @param Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function delete(Model $model): void;
|
||||
|
||||
/**
|
||||
* Fetch Model by Id
|
||||
* @param int $id
|
||||
* @return Model
|
||||
*/
|
||||
public function fetchById(int $id): Model;
|
||||
/**
|
||||
* Fetch all Models
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll(): array;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace ProVM\Implement\Model;
|
||||
|
||||
use ProVM\Concept\Model;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use ProVM\Concept\Model\Factory as FactoryInterface;
|
||||
use ProVM\Concept\Model\Repository;
|
||||
@ -26,4 +27,18 @@ class Factory implements FactoryInterface
|
||||
{
|
||||
return $this->getContainer()->get($repository_class);
|
||||
}
|
||||
public function getByModel(string $model_class): Repository
|
||||
{
|
||||
$class = str_replace('Model', 'Repository', $model_class);
|
||||
return $this->get($class);
|
||||
}
|
||||
|
||||
public function fetchById(string $model_class, int $id): Model
|
||||
{
|
||||
return $this->getByModel($model_class)->fetchById($id);
|
||||
}
|
||||
public function fetchAll(string $model_class): array
|
||||
{
|
||||
return $this->getByModel($model_class)->fetchAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user