2021-06-03 02:21:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin\Plugin\Materiels;
|
|
|
|
|
|
|
|
use Garradin\DB;
|
|
|
|
|
2021-06-03 19:30:07 +02:00
|
|
|
class Category
|
2021-06-03 02:21:52 +02:00
|
|
|
{
|
|
|
|
protected $id;
|
|
|
|
protected $name;
|
|
|
|
|
|
|
|
protected $_types = [
|
|
|
|
'id' => 'int',
|
|
|
|
'name' => 'string',
|
|
|
|
];
|
|
|
|
|
2021-06-03 19:30:07 +02:00
|
|
|
public function add($data = [])
|
|
|
|
{
|
|
|
|
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()
|
2021-06-03 02:21:52 +02:00
|
|
|
{
|
2021-06-03 19:30:07 +02:00
|
|
|
return DB::getInstance()->get('SELECT id, name FROM plugin_materiels_category ORDER BY name;');
|
2021-06-03 02:21:52 +02:00
|
|
|
}
|
|
|
|
}
|