Add method to find all webhooks of a certain type for a user

This commit is contained in:
osaajani 2020-01-06 23:39:30 +01:00
parent 03f29b2225
commit b6755dcc95
2 changed files with 24 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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]);
}
}