Create entry
Creates a new diary entry for the authenticated user. Supports uploading an image attachment and sharing the entry with specific friends.Endpoint
Authentication
This endpoint requires authentication via theauth middleware. Users must be logged in to create entries.
Request parameters
The main text content of the diary entry. This field is required and cannot be empty.
Controls the visibility of the entry. Determines who can see this diary entry.
An optional image file to attach to the entry. The file will be stored in the
uploads directory. Accepted formats include common image types (JPEG, PNG, etc.).An optional array of friend user IDs to share this entry with. The entry will be associated with the specified friends.
Response
On successful creation, the user is redirected to the home session with a success message.Returns
success_entry on successful entry creation.The unique identifier of the created entry.
The text content of the entry.
The visibility setting of the entry.
The ID of the authenticated user who created the entry.
The timestamp when the entry was created.
The timestamp when the entry was last updated.
Example request
Implementation details
- The entry is automatically associated with the authenticated user via
creator_id - If a file is uploaded, an
ImageEntryrecord is created with the original filename and storage path - Files are stored in the
public/uploadsdirectory - Friend associations are created using the
attach()method on the users relationship - Validation ensures the
bodyfield is present before creating the entry