From b6755dcc9569475888e742510af4e7b22390a21b Mon Sep 17 00:00:00 2001 From: osaajani Date: Mon, 6 Jan 2020 23:39:30 +0100 Subject: [PATCH] Add method to find all webhooks of a certain type for a user --- controllers/internals/Webhook.php | 12 ++++++++++++ models/Webhook.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/controllers/internals/Webhook.php b/controllers/internals/Webhook.php index 6bdab02..7dd3d62 100755 --- a/controllers/internals/Webhook.php +++ b/controllers/internals/Webhook.php @@ -68,4 +68,16 @@ namespace controllers\internals; return $this->get_model()->update_for_user($id_user, $id, $datas); } + + + /** + * Find all webhooks for a user and for a type of webhook + * @param int $id_user : User id + * @param string $type : Webhook type + * @return array + */ + public function gets_for_type_and_user (int $id_user, string $type) + { + return $this->get_model()->gets_for_type_and_user($id_user, $type); + } } diff --git a/models/Webhook.php b/models/Webhook.php index 27c2e79..d1b0245 100755 --- a/models/Webhook.php +++ b/models/Webhook.php @@ -18,4 +18,16 @@ namespace models; * @return string */ protected function get_table_name() : string { return 'webhook'; } + + + /** + * Find all webhooks for a user and for a type of webhook + * @param int $id_user : User id + * @param string $type : Webhook type + * @return array + */ + public function gets_for_type_and_user (int $id_user, string $type) + { + return $this->_select($this->get_table_name(), ['id_user' => $id_user, 'type' => $type]); + } }