Neuron-PHP

IPostRepository

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
bool

attachTags()

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
bool

count()

Count total posts

public count([string|null $status = null ]) : int
Parameters
$status : string|null = null

Filter by status

Return values
int

delete()

Delete a post

public delete(int $id) : bool
Parameters
$id : int
Return values
bool

detachCategories()

Detach all categories from post

public detachCategories(int $postId) : bool
Parameters
$postId : int
Return values
bool

detachTags()

Detach all tags from post

public detachTags(int $postId) : bool
Parameters
$postId : int
Return values
bool

findById()

Find post by ID

public findById(int $id) : Post|null
Parameters
$id : int
Return values
Post|null

findBySlug()

Find post by slug

public findBySlug(string $slug) : Post|null
Parameters
$slug : string
Return values
Post|null

getByAuthor()

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
bool

update()

Update an existing post

public update(Post $post) : bool
Parameters
$post : Post
Return values
bool

        
On this page

Search results