Auth, Login, Home, Venta->Listados->Precios

This commit is contained in:
Juan Pablo Vial
2023-07-24 20:55:26 -04:00
parent d9d5a15376
commit 1a7b10ce3c
130 changed files with 4302 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace Incoviba\Repository;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Model;
class User extends Ideal\Repository
{
public function __construct(Define\Connection $connection)
{
parent::__construct($connection);
$this->setTable('users');
}
public function create(?array $data = null): Define\Model
{
$map = [
'name' => [],
'password' => [],
'enabled' => [
'function' => function($data) {
return $data['enabled'] != 0;
}
]
];
return $this->parseData(new Model\User(), $data, $map);
}
public function save(Define\Model $model): Define\Model
{
$model->id = $this->saveNew(['name', 'password', 'enabled'], [$model->name, $model->password, $model->enabled ? 1 : 0]);
return $model;
}
public function edit(Define\Model $model, array $new_data): Define\Model
{
return $this->update($model, ['name', 'password', 'enabled'], $new_data);
}
public function fetchByName(string $name): Model\User
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `name` = ?";
return $this->fetchOne($query, [$name]);
}
}