2023-12-06 08:33:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Programmiert durch Samuel Wolff
|
2024-01-08 11:14:17 +01:00
|
|
|
// Getestet durch: Samuel Wolff
|
2023-12-06 08:33:25 +01:00
|
|
|
|
2023-12-14 16:59:16 +01:00
|
|
|
namespace ppb\Controller;
|
2023-12-06 08:33:25 +01:00
|
|
|
|
2023-12-14 16:59:16 +01:00
|
|
|
use ppb\Library\Msg;
|
|
|
|
use ppb\Model\KindModel;
|
2023-12-06 08:33:25 +01:00
|
|
|
|
2023-12-18 08:16:21 +01:00
|
|
|
class KindController
|
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
|
|
|
|
private $db;
|
|
|
|
|
2023-12-18 08:16:21 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
$this->db = new KindModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
// $parentId ist standardmäßig auf false und gibt damit alle Kinder aus,
|
|
|
|
// das setzen gibt nur Kinder eines bestimmten Benutzerkontos aus.
|
2023-12-18 08:16:21 +01:00
|
|
|
public function getKind($parentId = false)
|
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
$result = $this->db->getKind($parentId);
|
|
|
|
|
|
|
|
return json_encode($result);
|
|
|
|
}
|
|
|
|
|
2023-12-11 15:33:08 +01:00
|
|
|
// Updated ein Kind
|
2023-12-18 08:16:21 +01:00
|
|
|
public function updateKind($kindId, $data)
|
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
$result = $this->db->updateKind($kindId, $data);
|
|
|
|
|
|
|
|
return json_encode($result);
|
|
|
|
}
|
|
|
|
|
2023-12-11 15:33:08 +01:00
|
|
|
// Fügt ein Kind hinzu
|
2023-12-20 08:36:35 +01:00
|
|
|
public function writeKind($data)
|
2023-12-18 08:16:21 +01:00
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
$result = $this->db->addKind($data);
|
|
|
|
|
|
|
|
return json_encode($data);
|
|
|
|
}
|
|
|
|
|
2023-12-11 15:33:08 +01:00
|
|
|
// Löscht ein Kind
|
2023-12-18 08:16:21 +01:00
|
|
|
public function deleteKind($kindId)
|
|
|
|
{
|
2023-12-06 08:33:25 +01:00
|
|
|
$result = $this->db->deleteKind($kindId);
|
|
|
|
|
2024-01-19 09:19:35 +01:00
|
|
|
return json_encode($result);
|
2023-12-06 08:33:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|