From a6e76b524612f065e627d4486ff626cbd474097e Mon Sep 17 00:00:00 2001 From: Hendrik Bugdoll Date: Mon, 26 Feb 2024 13:35:29 +0100 Subject: [PATCH] Fixed website relation for nav container --- src/models/NavContainer.php | 5 +++-- tests/src/models/NavContainerTest.php | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/models/NavContainer.php b/src/models/NavContainer.php index 6f72f6af..178ed7f1 100644 --- a/src/models/NavContainer.php +++ b/src/models/NavContainer.php @@ -11,6 +11,7 @@ /** * Navigation-Containers Model. * + * @property integer $id * @property string $name * @property string $alias * @property integer $website_id @@ -58,7 +59,7 @@ public function rules() { return [ [['name', 'alias', 'website_id'], 'required'], - [['website_id', 'is_deleted', 'website_id'], 'integer'], + [['website_id'], 'integer'], [['is_deleted'], 'boolean'] ]; } @@ -113,6 +114,6 @@ public function getNavs() */ public function getWebsite() { - return $this->hasOne(Website::class, ['website_id' => 'id']); + return $this->hasOne(Website::class, ['id' => 'website_id']); } } diff --git a/tests/src/models/NavContainerTest.php b/tests/src/models/NavContainerTest.php index 998e67ab..65229612 100644 --- a/tests/src/models/NavContainerTest.php +++ b/tests/src/models/NavContainerTest.php @@ -46,6 +46,11 @@ public function testFindWebsiteContainer() $this->assertEquals(2, $navContainer->website_id); $this->assertSame('test container', $navContainer->name); + + $website = $navContainer->website; + + $this->assertEquals(2, $website->id); + $this->assertSame('test', $website->name); }); } }