30 Commits

Author SHA1 Message Date
d12f3f7897 Implement delete 2022-09-09 13:15:54 -04:00
3811e8224b Define and Implement delete 2022-09-09 13:15:27 -04:00
9834eb70a4 Use full class name without having to specify namespace beforehand 2022-09-09 13:15:11 -04:00
7fc7de7390 Added Factory implementation 2022-09-09 10:33:19 -04:00
55275d2d75 Factory Implementation 2022-09-09 10:31:38 -04:00
3bc54fb9d1 Second version 2022-09-08 21:42:32 -04:00
123d46d33c Fixed Model joins 2021-12-20 23:34:52 -03:00
65c224c636 Merge branch 'develop' into master 2021-08-01 20:51:44 -04:00
6cd26a88ea Merge branch 'develop' into master 2021-08-01 20:34:04 -04:00
022ba575b7 Merge branch 'develop' into master 2021-06-04 21:15:26 -04:00
c913f65b91 Considera leer el dato y correccion en los nombres de los metodos 2021-03-16 00:22:13 -03:00
c8a7781c88 Merge branch 'develop' 2021-03-15 11:17:11 -03:00
1505539e61 Merge branch 'develop' into master 2021-03-09 00:19:55 -03:00
3087a48c43 Merge branch 'develop' into master 2021-03-09 00:15:12 -03:00
43f545516d Merge branch 'develop' 2020-08-04 01:33:09 -04:00
b757ed19b2 Merge branch 'develop' 2020-08-03 23:54:16 -04:00
9dc71e4d77 Merge branch 'develop' 2020-08-03 23:51:05 -04:00
c6806a1c62 Merge branch 'develop' 2020-08-03 23:42:11 -04:00
6fd19a11be Merge branch 'develop' 2020-08-03 23:38:41 -04:00
7c727d93e9 Merge branch 'develop' 2020-08-03 23:27:45 -04:00
e02b8c4063 Merge branch 'develop' 2020-08-03 23:17:38 -04:00
89d1db7a7e Merge branch 'develop' 2020-08-03 23:10:57 -04:00
8dc0a27fd9 Merge branch 'develop' 2020-08-03 22:07:24 -04:00
ae172b902c Merge branch 'develop' 2020-08-03 16:25:19 -04:00
7f81b987c9 Merge branch 'develop' 2020-07-24 12:06:16 -04:00
af801e769f Merge branch 'develop' 2020-07-24 11:58:16 -04:00
c40baaad3f Merge branch 'develop' 2020-07-24 11:47:39 -04:00
a82fdce64b Merge branch 'develop' 2020-07-22 23:08:52 -04:00
8126b1f67d Merge branch 'develop' 2020-07-22 22:57:48 -04:00
2177cb4652 Merge branch 'develop' 2020-07-22 14:08:09 -04:00
6 changed files with 42 additions and 3 deletions

View File

@ -61,4 +61,8 @@ abstract class Model implements ModelInterface
} }
$this->isDirty(); $this->isDirty();
} }
public function delete(): void
{
$this->getFactory()->get(get_class($this))->delete($this);
}
} }

View File

@ -100,6 +100,12 @@ abstract class Repository implements RepositoryInterface
} }
return $model; return $model;
} }
public function delete(Model $model): void
{
$query = $this->getQueryBuilder()->delete($this->getTable())->where(['id = ?']);
$this->getConnection()->execute($query, [$model->getId()]);
}
public function fetchById(int $id): Model public function fetchById(int $id): Model
{ {
$query = $this->getQueryBuilder() $query = $this->getQueryBuilder()

View File

@ -15,4 +15,5 @@ interface Model
public function isDirty(): bool; public function isDirty(): bool;
public function save(): void; public function save(): void;
public function edit(array $data): void; public function edit(array $data): void;
public function delete(): void;
} }

View File

@ -7,7 +7,5 @@ interface Factory
{ {
public function setContainer(ContainerInterface $container): Factory; public function setContainer(ContainerInterface $container): Factory;
public function getContainer(): ContainerInterface; public function getContainer(): ContainerInterface;
public function setNamespace(string $namespace): Factory; public function get(string $repository_class): Repository;
public function getNamespace(): string;
public function get(string $repository_name): Repository;
} }

View File

@ -23,6 +23,7 @@ interface Repository
public function save(Model $model): void; public function save(Model $model): void;
public function edit(Model $model, array $data): Model; public function edit(Model $model, array $data): Model;
public function create(array $data): Model; public function create(array $data): Model;
public function delete(Model $model): void;
public function fetchById(int $id): Model; public function fetchById(int $id): Model;
public function fetchAll(): array; public function fetchAll(): array;
} }

View File

@ -0,0 +1,29 @@
<?php
namespace ProVM\Implement\Model;
use Psr\Container\ContainerInterface;
use ProVM\Concept\Model\Factory as FactoryInterface;
use ProVM\Concept\Model\Repository;
class Factory implements FactoryInterface
{
public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
}
protected ContainerInterface $container;
public function setContainer(ContainerInterface $container): FactoryInterface
{
$this->container = $container;
return $this;
}
public function getContainer(): ContainerInterface
{
return $this->container;
}
public function get(string $repository_class): Repository
{
return $this->getContainer()->get($repository_class);
}
}