diff --git a/src/lib/Category.php b/src/lib/Category.php index 1694006..b1da912 100644 --- a/src/lib/Category.php +++ b/src/lib/Category.php @@ -2,13 +2,10 @@ namespace Garradin\Plugin\Materiels; -use Garradin\Entity; use Garradin\DB; -class Category extends Entity +class Category { - const TABLE = 'plugin_materiels_category'; - protected $id; protected $name; @@ -17,8 +14,23 @@ class Category extends Entity 'name' => 'string', ]; - static public function listAll(): array + public function add($data = []) { - return DB::getInstance()->get('SELECT id, name FROM plugin_materiels_category ORDER BY name COLLATE NOCASE;'); + DB::getInstance()->insert('plugin_materiels_category', $data); + } + + public function delete($id) + { + DB::getInstance()->delete('plugin_facturation_clients', 'id = ' . $id); + } + + public function get($id) + { + return DB::getInstance()->first('SELECT * FROM plugin_materiels_category WHERE id = ?;', $id); + } + + public function listAll() + { + return DB::getInstance()->get('SELECT id, name FROM plugin_materiels_category ORDER BY name;'); } } diff --git a/src/templates/_nav.tpl b/src/templates/_nav.tpl index 68a2f6b..323a59a 100644 --- a/src/templates/_nav.tpl +++ b/src/templates/_nav.tpl @@ -1,7 +1,7 @@