From ba1ffd5cc6b3553d8cc25197efb1e1178492cfc3 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Tue, 17 Mar 2020 21:49:39 -0600 Subject: [PATCH] Fix category creation & updating Signed-off-by: William Brawner --- lib/Controller/CategoryController.php | 5 +++-- lib/Db/Category.php | 4 +++- lib/Migration/Version000001Date20200204101200.php | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Controller/CategoryController.php b/lib/Controller/CategoryController.php index a85b777..a223497 100644 --- a/lib/Controller/CategoryController.php +++ b/lib/Controller/CategoryController.php @@ -88,7 +88,7 @@ class CategoryController extends Controller * @param int amount * @param bool expense */ - public function create(string $name, int $amount, int $budgetId, bool $expense) + public function create(string $name, ?string $description, int $amount, int $budgetId, bool $expense) { try { $userPermission = $this->userPermissionMapper->find($budgetId, $this->userId); @@ -100,6 +100,7 @@ class CategoryController extends Controller } $category = new Category(); $category->setName($name); + $category->setDescription($description); $category->setAmount($amount); $category->setExpense($expense); $category->setBudgetId($budgetId); @@ -115,7 +116,7 @@ class CategoryController extends Controller * @param string $description * @param array $users */ - public function update(int $id, string $name, string $description, int $amount, int $budgetId, bool $expense) + public function update(int $id, string $name, ?string $description, int $amount, int $budgetId, bool $expense) { try { $category = $this->categoryMapper->find($id); diff --git a/lib/Db/Category.php b/lib/Db/Category.php index d6685f9..c12f13f 100644 --- a/lib/Db/Category.php +++ b/lib/Db/Category.php @@ -8,6 +8,7 @@ use OCP\AppFramework\Db\Entity; class Category extends Entity implements JsonSerializable { protected $name; + protected $description; protected $amount; protected $expense; protected $budgetId; @@ -16,9 +17,10 @@ class Category extends Entity implements JsonSerializable { return [ 'id' => (int) $this->id, 'name' => $this->name, + 'description' => $this->description, 'amount' => (int) $this->amount, 'expense' => (bool) $this->expense, 'budgetId' => (int) $this->budgetId, ]; } -} \ No newline at end of file +} diff --git a/lib/Migration/Version000001Date20200204101200.php b/lib/Migration/Version000001Date20200204101200.php index f61d97d..e9d9635 100644 --- a/lib/Migration/Version000001Date20200204101200.php +++ b/lib/Migration/Version000001Date20200204101200.php @@ -51,6 +51,10 @@ class Version000001Date20200204101200 extends SimpleMigrationStep { 'notnull' => true, 'length' => 200 ]); + $table->addColumn('description', 'string', [ + 'notnull' => true, + 'length' => 1000 + ]); $table->addColumn('amount', 'integer', [ 'notnull' => true, ]);