From ac2e082d488876fc28ddbc3f75fe88eb52a7d9b5 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 6 Oct 2017 15:44:14 +0200 Subject: [PATCH] Add getIdByName function to Category class --- Changelog | 1 + nntmux/Category.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Changelog b/Changelog index 97027f52e..ed29d4293 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-10-06 DariusIII + * Chg: Add getIdByName function to Category class * Chg: Update services.php with proper user model * Fix: Fix category display on pages * Chg: Update cs of some files, use Category model in Category class diff --git a/nntmux/Category.php b/nntmux/Category.php index b7c356a4f..351281082 100755 --- a/nntmux/Category.php +++ b/nntmux/Category.php @@ -313,6 +313,18 @@ class Category return $cat !== null ? $cat->parent->title.' -> '.$cat->title : ''; } + /** + * @param $title + * @param $parent + * @return bool|mixed + */ + public function getIdByName($title, $parent) + { + $cat = CategoryModel::query()->where('title', $title)->with('parent.' . $parent)->first(['id']); + + return $cat !== null ? $cat->id : false; + } + /** * Update a category. *