Skip to content

Commit

Permalink
Fix parent nav id assignment in NavItem model
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Feb 21, 2024
1 parent 1086b5b commit 7ae9b83
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/models/NavItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,17 @@ public function verifyAlias($alias, $langId)
return false;
}

// when no parent nav id is given, the post value is `null` therefore we have the explicit set the value to `0`.
$parentNavId = $this->parent_nav_id ?: 0;

/**
* Group by website_id
* @since 4.0.0
*/
$exists = static::find()
->leftJoin('cms_nav', 'cms_nav_item.nav_id=cms_nav.id')
->leftJoin('cms_nav_container', 'cms_nav.nav_container_id=cms_nav_container.id')
->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $this->parent_nav_id])
->where(['cms_nav_item.alias' => $alias, 'cms_nav_item.lang_id' => $langId, 'cms_nav.parent_nav_id' => $parentNavId])
->groupBy('cms_nav_container.website_id')
->exists();
if ($exists) {
Expand Down

0 comments on commit 7ae9b83

Please sign in to comment.