Add getIdByName function to Category class

This commit is contained in:
DariusIII
2017-10-06 15:44:14 +02:00
parent abc0b50350
commit ac2e082d48
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -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
+12
View File
@@ -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.
*