Modify categories
This commit is contained in:
parent
2f9b57a842
commit
5f226732ad
9 changed files with 110 additions and 42 deletions
|
|
@ -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;');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue