Skip to content

Commit b2500c8

Browse files
committed
wip
1 parent 320a6d7 commit b2500c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Models/PostType.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Javaabu\Cms\Models;
44

55
use Illuminate\Database\Eloquent\Relations\BelongsTo;
6+
use Illuminate\Database\Eloquent\Relations\HasMany;
67
use Illuminate\Support\Str;
78
use Javaabu\Cms\Enums\PostTypeFeatures;
89
use Javaabu\Helpers\AdminModel\AdminModel;
@@ -107,6 +108,24 @@ public function getFeatureCollectionName($feature): ?string
107108
return PostTypeFeatures::getCollectionName($feature);
108109
}
109110

111+
/**
112+
* A post type has many posts
113+
*/
114+
public function userVisiblePosts()
115+
{
116+
return $this->posts()->userVisibleForPostType($this);
117+
}
118+
119+
/**
120+
* A post type has many posts
121+
*
122+
* @return HasMany
123+
*/
124+
public function posts(): HasMany
125+
{
126+
return $this->hasMany(Post::class, 'type', 'slug');
127+
}
128+
110129
/**
111130
* Slugify the value
112131
*

0 commit comments

Comments
 (0)