IPostRepository
in
Post repository interface.
Table of Contents
Methods
- all() : array<string|int, Post>
- Get all posts
- attachCategories() : bool
- Attach categories to post
- attachTags() : bool
- Attach tags to post
- count() : int
- Count total posts
- create() : Post
- Create a new post
- delete() : bool
- Delete a post
- detachCategories() : bool
- Detach all categories from post
- detachTags() : bool
- Detach all tags from post
- findById() : Post|null
- Find post by ID
- findBySlug() : Post|null
- Find post by slug
- getByAuthor() : array<string|int, Post>
- Get posts by author
- getByCategory() : array<string|int, Post>
- Get posts by category
- getByTag() : array<string|int, Post>
- Get posts by tag
- getDrafts() : array<string|int, Post>
- Get draft posts
- getPublished() : array<string|int, Post>
- Get published posts
- getScheduled() : array<string|int, Post>
- Get scheduled posts
- incrementViewCount() : bool
- Increment post view count
- update() : bool
- Update an existing post
Methods
all()
Get all posts
public
all([string|null $status = null ][, int $limit = 0 ][, int $offset = 0 ]) : array<string|int, Post>
Parameters
- $status : string|null = null
-
Filter by status (published, draft, scheduled)
- $limit : int = 0
-
Limit number of results (0 = no limit)
- $offset : int = 0
-
Offset for pagination
Return values
array<string|int, Post>attachCategories()
Attach categories to post
public
attachCategories(int $postId, array<string|int, mixed> $categoryIds) : bool
Parameters
- $postId : int
-
Post ID
- $categoryIds : array<string|int, mixed>
-
Array of category IDs
Return values
boolattachTags()
Attach tags to post
public
attachTags(int $postId, array<string|int, mixed> $tagIds) : bool
Parameters
- $postId : int
-
Post ID
- $tagIds : array<string|int, mixed>
-
Array of tag IDs
Return values
boolcount()
Count total posts
public
count([string|null $status = null ]) : int
Parameters
- $status : string|null = null
-
Filter by status
Return values
intcreate()
Create a new post
public
create(Post $post) : Post
Parameters
- $post : Post
Return values
Postdelete()
Delete a post
public
delete(int $id) : bool
Parameters
- $id : int
Return values
booldetachCategories()
Detach all categories from post
public
detachCategories(int $postId) : bool
Parameters
- $postId : int
Return values
booldetachTags()
Detach all tags from post
public
detachTags(int $postId) : bool
Parameters
- $postId : int
Return values
boolfindById()
Find post by ID
public
findById(int $id) : Post|null
Parameters
- $id : int
Return values
Post|nullfindBySlug()
Find post by slug
public
findBySlug(string $slug) : Post|null
Parameters
- $slug : string
Return values
Post|nullgetByAuthor()
Get posts by author
public
getByAuthor(int $authorId[, string|null $status = null ]) : array<string|int, Post>
Parameters
- $authorId : int
-
Author user ID
- $status : string|null = null
-
Filter by status
Return values
array<string|int, Post>getByCategory()
Get posts by category
public
getByCategory(int $categoryId[, string|null $status = null ]) : array<string|int, Post>
Parameters
- $categoryId : int
-
Category ID
- $status : string|null = null
-
Filter by status
Return values
array<string|int, Post>getByTag()
Get posts by tag
public
getByTag(int $tagId[, string|null $status = null ]) : array<string|int, Post>
Parameters
- $tagId : int
-
Tag ID
- $status : string|null = null
-
Filter by status
Return values
array<string|int, Post>getDrafts()
Get draft posts
public
getDrafts() : array<string|int, Post>
Return values
array<string|int, Post>getPublished()
Get published posts
public
getPublished([int $limit = 0 ][, int $offset = 0 ]) : array<string|int, Post>
Parameters
- $limit : int = 0
-
Limit number of results (0 = no limit)
- $offset : int = 0
-
Offset for pagination
Return values
array<string|int, Post>getScheduled()
Get scheduled posts
public
getScheduled() : array<string|int, Post>
Return values
array<string|int, Post>incrementViewCount()
Increment post view count
public
incrementViewCount(int $id) : bool
Parameters
- $id : int
Return values
boolupdate()
Update an existing post
public
update(Post $post) : bool
Parameters
- $post : Post