Event Model Fields
Every event is stored in theevents table. The table is defined by the migration below and the corresponding Event Eloquent model.
bigint
required
Auto-incrementing primary key.
string
required
Public-facing title of the event.
text
required
Full description of the event shown on the event detail page.
string
required
Relative storage path to the event’s cover image (e.g.
images/example.jpg). Served via the public disk.integer
required
Remaining tickets available for purchase. Decremented on each ticket sale.
integer
Running count of tickets sold. Incremented on each ticket sale. Defaults to
0.integer
required
Ticket price in the application’s base currency unit.
datetime
required
Date and time the event begins.
datetime
required
Date and time the event ends.
bigint
Foreign key referencing the
users table. Set to null if the owning user is deleted.bigint
Foreign key referencing the
locations table. Set to null if the location is deleted.bigint
Foreign key referencing the
categories table. Set to null if the category is deleted.bigint
Foreign key referencing the
statuses table. Defaults to 1 (Disponible). Set to null if the status is deleted.timestamp
Column defined by
$table->softDeletes() in the migration. Note: the Event model does not use the SoftDeletes trait, so this column is not automatically managed by Eloquent.Creating Events
Authenticated users (and admins) create events through the dashboard atGET /dashboard/events/create. The creation form collects the following fields:
When the form is submitted to
POST /dashboard/events/store, EventController::store() runs the following sequence:
1
Create the Location record
A new
Location is instantiated and populated with country, city, region, and address from the request.2
Geocode the address via Nominatim
The controller builds a combined address string (Coordinates are stored on the
address, city) and issues a GET request to the Nominatim OpenStreetMap API using a Guzzle HTTP client:Location record. If the Nominatim lookup returns no results, latitude and longitude are saved as null.3
Save the Location
$location->save() persists the record and provides the id needed for the foreign key.4
Build the Event
A new
Event is instantiated and all form fields are assigned, including user_id from auth()->id() and location_id from the saved location.5
Upload the cover image
If an image was included in the request, it is stored in the
public disk under the images/ directory:6
Auto-assign status
The event’s status is determined automatically based on the initial capacity:
7
Save the Event
$event->save() persists the record, and the user is redirected to /dashboard/events with a success message.Editing Events
Organizers can edit their events viaGET /dashboard/events/edit/{event}, which loads the edit form pre-populated with the existing values. Changes are submitted via PATCH /dashboard/events/{event}, handled by EventController::update().
The update logic handles two important cases:
Image replacement — If a new image file is uploaded, the controller deletes the old image from storage before saving the new one:
Location record. Re-geocoding is triggered only when something has actually changed, avoiding unnecessary API calls:
Event Status
Status is automatically managed by the application and reflects the current availability of an event. The assignment logic is applied both at creation time and during ticket purchases:
See Categories & Status for the full list of status labels and their meanings.
Deleting Events
Events are deleted viaDELETE /dashboard/events/delete/{event}, handled by EventController::destroy():
events table migration defines a deleted_at column via $table->softDeletes(), but the Event model does not use the SoftDeletes trait. As a result, $event->delete() performs a hard delete — the row is permanently removed from the database. Ticket records and any other data referencing the deleted event’s ID will lose their association.
Explore Page
The public/explore route displays all events to unauthenticated and authenticated visitors alike. Events are ordered from newest to oldest:
/) uses the same ordering logic via showHome(), providing a consistent discovery experience across both surfaces.
PDF Reports
Authenticated users can download a PDF summary of any event by visiting:EventController::downloadEventReport() method loads the reports.event-report Blade view and streams it as a PDF download using the DomPDF library:
event-{id}.pdf. The report view receives the full $event model instance, including its related location, category, status, and ticket data.
The PDF report route is defined outside the
/dashboard prefix group and carries no auth middleware. It is publicly accessible to any visitor who knows or guesses the event ID. If you want to restrict report downloads to authenticated users, add the auth middleware to this route in routes/web.php.Relationships
TheEvent model declares the following Eloquent relationships:
User
The organizer who created the event. Foreign key
user_id; set to null on user deletion.Location
A dedicated
locations record holding address, city, region, country, and geocoded latitude/longitude.Category
One of the seeded categories (Musical, Teatro, Deportivo, etc.) used for filtering and discovery.
Status
Reflects current availability — Disponible, Agotado, or Finalizado.