Post Creation & Management
Relevant source files
The following files were used as context for generating this wiki page:
Post Creation & Management within RateGuru encompasses the lifecycle of a post from initial upload and validation to moderation, public display, and eventual deletion. The system is built on a TDD-driven Laravel stack utilizing Livewire for interactive front-end components and Filament for administrative oversight.
The architecture prioritizes thin controllers and components, delegating heavy lifting to dedicated Action classes. This ensures that business logic, such as trust-level-based auto-publishing and rate limiting, remains decoupled from the UI.
Post Creation Workflow
The creation of a post is handled through a structured pipeline that includes rate limiting, authorization checks, and conditional status assignment based on the user's trust level.
Execution Logic
The CreatePostAction handles the core logic. It first validates the user's ability to create content and checks against configured rate limits for uploads. If the user meets the TRUSTED_LEVEL threshold, the post is automatically set to Published; otherwise, it remains Pending.
Data Handling
Post data is encapsulated in a CreatePostData object. During the database transaction, the system stores the primary image via ImageStorage, creates the post record, and synchronizes associated tags.
| Field | Description | Type |
|---|---|---|
title | The headline of the post | String |
description | Optional detailed text | String (Nullable) |
image | Uploaded file binary | File (Nullable) |
status | Published, Pending, or Hidden | Enum |
category_option_id | ID from the active rating configuration | Integer |
Sources: app/Actions/Posts/CreatePostAction.php:57-80, lang/en/ui.php:143-160
Content Management & Moderation
Management occurs at two levels: user-facing management (deletion of owned posts) and administrative moderation via the Filament-based back-end.
Administrative Interface
Administrators and Moderators use the PostResource to manage the global feed. The interface provides advanced filtering and status management.
- Filters: Capability to filter by status (
pending,published,hidden) and by report count (reported). - Search/Sort: Titles and Author usernames are searchable and sortable to maintain feed quality.
- N+1 Prevention: The system eager-loads authors in the administration table to ensure performance.
Sources: tests/Feature/Filament/PostResourceTest.php:97-175
User-Side Management
Users interact with their posts through the PostShow and PostDrawerContent components. These components facilitate actions like sharing, reporting (for other users), and deletion (for owners).
UI & Presentation Layer
The presentation layer is split between a full-page view and a side-drawer preview for the feed.
Detailed View (PostShow)
The PostShow component provides a high-fidelity view of the post, including:
- Metadata: Author avatar, username, and relative publication time.
- Visuals: A hero image section with zoom-in/fullscreen capabilities.
- Interaction: Voting controls (binary and rating groups) and a dedicated comments section.
- SEO: Dynamic OpenGraph and Twitter meta tags based on post content.
Sources: resources/views/livewire/posts/post-show.blade.php:1-60, app/Livewire/Posts/PostShow.php
Component Architecture
Post management UI elements are organized into reusable Blade components to maintain consistency with the "PlateRate" design contract.
| Component | Usage | Source |
|---|---|---|
x-ui.avatar | Displays user profile images | resources/views/livewire/posts/post-show.blade.php:40 |
x-ui.modal | Used for delete confirmation and image zooms | resources/views/livewire/posts/post-show.blade.php:180 |
livewire:posts.post-voting | Handles the upvote/downvote logic | resources/views/livewire/posts/post-show.blade.php:107 |
livewire:voting.rating-voting | Manages configurable rating groups | resources/views/livewire/posts/post-show.blade.php:94 |
Summary
The Post Creation & Management system provides a robust framework for content lifecycle management. By utilizing a combination of synchronous Actions and asynchronous Jobs (for image processing and notifications), the system remains responsive while ensuring data integrity and community standards through a multi-tiered moderation and trust-level system.