BlogController
TheBlogController handles blog post management operations in the admin panel, including CRUD operations for posts with support for categories, tags, and images.
Namespace: App\Http\Controllers\BlogController
index()
Display a paginated listing of all blog posts in the admin panel. Route:GET /admin/blog/posts (admin.blog.posts)
Returns: View - Admin blog posts listing page
Example:
create()
Show the form for creating a new blog post. Route:GET /admin/blog/create (admin.blog.create)
Post model instance for authorization
create permission on Post model
Returns: View - Blog post creation form with categories and tags
Example:
store()
Store a newly created blog post in storage. Route:POST /admin/blog/posts (admin.blog.store)
HTTP request containing post data
Post model instance
title: required, unique, min:8, max:255post_image: file (optional)body: requiredslug: required, unique in posts tablecategory_id: nullable, must exist in blog_categoriestags: nullable arraytags.*: must exist in tags table
create permission on Post class
Returns: RedirectResponse - Redirects to admin blog posts list
Example:
edit()
Show the form for editing a specific blog post. Route:GET /admin/blog/posts/{post}/edit (admin.blog.edit)
The post instance to edit (route model binding)
View - Blog post edit form with post data, categories, and tags
Example:
update()
Update a specific blog post in storage. Route:PATCH /admin/blog/posts/{post}/update (admin.blog.update)
HTTP request containing updated post data
The post instance to update (route model binding)
title: required, min:8, max:255, unique except current postpost_image: file (optional)body: requiredcategory_id: nullable, must exist in blog_categoriestags: nullable arraytags.*: must exist in tags table
update permission on the post
Returns: RedirectResponse - Redirects to admin blog posts list
Example:
show()
Display a specific blog post by slug. Route:GET /admin/blog/posts/{post} (admin.blog.show)
The unique slug identifier for the post
View - Blog post detail page
Example:
destroy()
Remove a specific blog post from storage. Route:DELETE /admin/blog/posts/{post} (admin.blog.destroy)
The post instance to delete (route model binding)
delete permission on the post
Returns: RedirectResponse - Redirects back to previous page
Example:
PostController
ThePostController handles public-facing blog post display operations for the frontend.
Namespace: App\Http\Controllers\PostController
index()
Display a paginated listing of published blog posts on the public blog page. Route:GET /blog (blog.index)
Returns: View - Public blog index with paginated posts
Example:
show()
Display a specific blog post by slug on the public blog. Route:GET /blog/{slug} (blog.show)
The unique slug identifier for the post
View - Public blog post detail page
Throws: ModelNotFoundException if post not found
Example: