diff --git a/appinfo/info.xml b/appinfo/info.xml index cb9f235..6a2d3b5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -17,7 +17,7 @@ - grocerylist + Grocerylist grocerylist.GroceryList.index diff --git a/lib/Controller/GroceryListController.php b/lib/Controller/GroceryListController.php index adf7a3a..2f9a70c 100644 --- a/lib/Controller/GroceryListController.php +++ b/lib/Controller/GroceryListController.php @@ -311,6 +311,6 @@ public function updateCategory(int $id, string $newName) */ public function sharees(int $id): DataResponse { - return new DataResponse($this->shareeMapper->find($id)); + return new DataResponse($this->shareeMapper->findSharees($id)); } } diff --git a/lib/Db/Sharee.php b/lib/Db/Sharee.php index cdb401c..4a91e56 100644 --- a/lib/Db/Sharee.php +++ b/lib/Db/Sharee.php @@ -16,7 +16,7 @@ class Sharee extends Entity implements JsonSerializable { /** * @var int */ - protected $list; + public $list; /** * @var string diff --git a/lib/Db/ShareeGroceryListMapper.php b/lib/Db/ShareeGroceryListMapper.php index 70e11b0..c31e567 100644 --- a/lib/Db/ShareeGroceryListMapper.php +++ b/lib/Db/ShareeGroceryListMapper.php @@ -2,6 +2,7 @@ namespace OCA\GroceryList\Db; +use OCP\DB\Exception; use OCP\IDBConnection; use OCP\AppFramework\Db\QBMapper; @@ -28,6 +29,22 @@ public function find(int $id) : Sharee { return $this->findEntities($qb)[0]; } + /** + * @throws Exception + */ + public function findSharees(int $id) : array { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('list', $qb->createNamedParameter($id))); + + return $this->findEntities($qb); + } + + /** + * @throws Exception + */ public function findAll(): array { $qb = $this->db->getQueryBuilder();