Skip to content

Commit 5e165fb

Browse files
committed
update model term relationships
1 parent 44b6b3b commit 5e165fb

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/Models/Category.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@
66
class Category extends WPTerm
77
{
88
public const TAXONOMY = 'category';
9+
10+
public function posts()
11+
{
12+
return $this->belongsToPost(Post::class);
13+
}
914
}

app/Models/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class Post extends WPPost
99

1010
public function categories()
1111
{
12-
return $this->belongsToTaxonomy(Category::class, 'category');
12+
return $this->belongsToTaxonomy(Category::class, Category::TAXONOMY);
1313
}
1414

1515
public function tags()
1616
{
17-
return $this->belongsToTaxonomy(Tag::class, 'post_tag');
17+
return $this->belongsToTaxonomy(Tag::class, Tag::TAXONOMY);
1818
}
1919
}

app/Models/Tag.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@
66
class Tag extends WPTerm
77
{
88
public const TAXONOMY = 'post_tag';
9+
10+
public function posts()
11+
{
12+
return $this->belongsToPost(Post::class);
13+
}
914
}

0 commit comments

Comments
 (0)