Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Feb 28, 2024
1 parent 5cd91c1 commit 6e9d6d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
15 changes: 5 additions & 10 deletions plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,14 @@ public function hasChild($id)
* @param int $blogContentId
* @param string $name
* @param array $options
* @return array|null
* @return EntityInterface
*/
public function getByName($blogContentId, $name, $options = [])
{
$options = array_merge([
'conditions' => [
'BlogCategory.blog_content_id' => $blogContentId,
'BlogCategory.name' => urlencode($name),
],
'recursive' => -1
], $options);
$this->unbindModel(['hasMany' => ['BlogPost']]);
return $this->find('first', $options);
return $this->find()->where([
'BlogCategories.blog_content_id' => $blogContentId,
'BlogCategories.name' => urlencode($name),
])->first();
}

/**
Expand Down
6 changes: 1 addition & 5 deletions plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2031,12 +2031,8 @@ public function getCategoryByName($blogContentId, $categoryName = '', $options =
$pass = $this->_View->getRequest()->getParam('pass');
$categoryName = $pass[count($pass) - 1];
}

$blogCategoriesModel = TableRegistry::getTableLocator()->get('BcBlog.BlogCategories');
return $blogCategoriesModel->find()->where([
'BlogCategories.blog_content_id' => $blogContentId,
'BlogCategories.name' => urlencode($categoryName),
])->first();
return $blogCategoriesModel->getByName($blogContentId, $categoryName, $options);
}

/**
Expand Down

0 comments on commit 6e9d6d9

Please sign in to comment.