Overview
TheBlogCategory model represents a category for blog posts in LaraCMS. Categories help organize posts into logical groupings, and posts can belong to multiple categories through a many-to-many relationship.
Namespace: App\Models\BlogCategory
File: app/Models/BlogCategory.php:7
Properties
Fillable attributes
The name of the category (e.g., “Technology”, “Tutorials”, “News”)
Relationships
posts()
Many-to-many relationship with the Post model. Returns:BelongsToMany<Post>
Pivot table: blog_category_post
Usage examples
Creating a category
Assigning categories to a post
Querying posts by category
Database schema
Theblog_categories table contains:
id- Primary keyname- Category name (string)created_at- Timestampupdated_at- Timestamp
blog_category_post contains:
blog_category_id- Foreign key to blog_categoriespost_id- Foreign key to posts
Related documentation
Post model
View Post model documentation
Blog feature
Learn about the blog feature