Add location, image, performer, status etc to Event schema

Merged
US
10d ago
+188-0

Problem

The Event schema added in #13 exposes name, description, startDate, endDate, doorTime, offers and organizer, but not location. Google's Event structured-data guidelines list location as a required property alongside name and startDate (items missing a required property are not eligible for rich results), and it's a core property of the schema.org Event type. As shipped, the typed builder can't produce a rich-result-eligible Event without falling back to the untyped set().

It also lacks the recommended image, performer, eventStatus and eventAttendanceMode properties, while Product and Article already expose image().

Change

Laravel\Head\Schema\Event gains:

  • location(SchemaObject|string $location) accepts a schema object (normally a Place), or a plain string which is treated as the venue name and wrapped in a Place.
  • image(string|array $image) same shape as Product::image().
  • performer(Organization|Person|array $performer) single or list, same shape as offers().
  • eventStatus(EventStatus $status) and eventAttendanceMode(EventAttendanceMode $mode) new backed enums following the OfferAvailability pattern, rendered as https://schema.org/... URLs.

New Laravel\Head\Schema\Place (name, address, url) is registered in SchemaFactory and the Schema facade docblock, so Schema::place() works like every other built-in type.

Example

Head::schema(
    Schema::event()
        ->name('Laracon US')
        ->startDate($event->starts_at)
        ->endDate($event->ends_at)
        ->location(Schema::place()->name('City Center')->address('Nashville, TN'))
        ->image($event->hero_image_url)
        ->eventStatus(EventStatus::Scheduled)
        ->eventAttendanceMode(EventAttendanceMode::Offline)
        ->offers(Schema::offer()->price(499)->currency('USD')->availability(OfferAvailability::InStock))
);

Tests

tests/Feature/Schema/EventSchemaTest.php (the Event schema previously had no tests):

  • renders a full Event with Place location through Head::toHtml()
  • string location becomes {"@type":"Place","name":"..."}
  • status / attendance-mode enums render as schema.org URLs
  • image list, performer list, organizer and offers coerce correctly
  • Schema::place() is a first-class factory method
  • enum url() coverage