Skip to content

domos-technologies/schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo
domos/schema

© 2024 domos GmbH

Warning

Not ready for public use yet. API surface is subject to change.


domos/schema is the reference implementation of the domos real estate data schema written in PHP.

composer install domos/schema

Schema Documentation

Table of Contents

  1. Introduction
  2. Accessing Estate Data in WordPress
  3. Core Models
  4. Location Models
  5. Media Models
  6. Financial Models
  7. Web Expose Models
  8. Utility Models

Introduction

This document provides a comprehensive overview of the real estate data schema implemented in PHP. The schema is designed to represent various aspects of real estate properties, including buildings, rentable spaces, locations, media assets, and web exposures. It uses modern PHP features such as typed properties, enums, and interfaces to create a robust and flexible system for managing real estate data.

Accessing Estate Data in WordPress

The EstatePost class provides a bridge between the Estate data schema and WordPress, allowing you to retrieve and display estate information stored as WordPress posts. This section explains how to use the EstatePost class to access estate data within a WordPress environment, focusing on tasks relevant to building websites.

Finding an Estate

To retrieve an estate by its external ID:

$externalId = 'your-external-id';
$estatePost = EstatePost::find($externalId);

if ($estatePost !== null) {
    $estate = $estatePost->data; // This is an instance of SchemaImmo\Estate
    echo "Estate Name: " . $estate->name;
    echo "Estate Address: " . $estate->address->street . " " . $estate->address->number;
} else {
    echo "Estate not found";
}

Accessing Estate Data in WordPress Templates

When working with estate data in WordPress templates, you can use the EstatePost::fromPost() method to get the estate data from the current post:

global $post;

if ($post->post_type === EstatePost::POST_TYPE) {
    $estatePost = EstatePost::fromPost($post);
    $estate = $estatePost->data;

    // Now you can access all the estate data
    echo "<h1>{$estate->name}</h1>";
    echo "<p>Address: {$estate->address->street} {$estate->address->number}, {$estate->address->city}</p>";

    if ($estate->media->thumbnail) {
        echo "<img src='{$estate->media->thumbnail->src}' alt='{$estate->media->thumbnail->alt}'>";
    }

    // Display features
    if (!empty($estate->features)) {
        echo "<h2>Features:</h2><ul>";
        foreach ($estate->features as $feature => $value) {
            echo "<li>{$feature}: {$value}</li>";
        }
        echo "</ul>";
    }

    // Display rentable spaces
    if (!empty($estate->buildings)) {
        foreach ($estate->buildings as $building) {
            echo "<h2>Building: {$building->name}</h2>";
            foreach ($building->rentables as $rentable) {
                echo "<h3>Rentable Space: {$rentable->name}</h3>";
                echo "<p>Area: {$rentable->area} sqm</p>";
                echo "<p>Price: {$rentable->price->base->amount} {$rentable->price->base->currency->value}</p>";
            }
        }
    }
}

This example demonstrates how to access and display various aspects of the estate data within a WordPress template.

Finding Multiple Estates

To retrieve multiple estates, you can use WordPress's WP_Query class in combination with EstatePost::fromPost():

$args = array(
    'post_type' => EstatePost::POST_TYPE,
    'posts_per_page' => 10,
    // Add any other query arguments as needed
);

$query = new WP_Query($args);

if ($query->have_posts()) {
    while ($query->have_posts()) {
        $query->the_post();
        $estatePost = EstatePost::fromPost($query->post);
        $estate = $estatePost->data;

        // Display estate information
        echo "<h2>{$estate->name}</h2>";
        echo "<p>{$estate->address->city}, {$estate->address->country}</p>";
        // Add more fields as needed
    }
    wp_reset_postdata();
} else {
    echo "No estates found";
}

This example shows how to query for multiple estates and display basic information for each.

Estate Management Operations (Internal Use)

The following operations are primarily for internal use and data management:

  • Creating a new estate: EstatePost::create($externalId, $estateData)
  • Updating an existing estate: EstatePost::update($externalId, $updatedEstateData)
  • Deleting an estate: EstatePost::delete($externalId)
  • Finding unneeded estates: EstatePost::findUnneeded($activeIds)

These methods should be used with caution and typically within administrative interfaces or background processes, rather than in public-facing website code.

By using the EstatePost class, you can seamlessly integrate the real estate data schema with WordPress, allowing for easy retrieval and display of complex estate information on your WordPress site.

Core Models

Estate

The Estate class is the central model representing a real estate property.

Property Type Description
id string Unique identifier
slug string URL-friendly identifier
name string Name of the estate
address Address Physical address of the estate
features array List of features and amenities
buildings array List of Building objects within the estate
texts Texts Descriptive content about the estate
media Media Images, videos, and 3D scans related to the estate
location Location Geographical location and nearby places
certifications Certifications Environmental and quality certifications
social Social Social media and contact information
expose ?WebExpose Web-based property exposure data

Usage:

$estate = new Estate(
    id: '123',
    slug: 'sample-estate',
    name: 'Sample Estate',
    address: new Address(
        street: 'Main St',
        number: '123',
        postal_code: '12345',
        city: 'Sample City',
        country: 'US'
    )
);
$arrayRepresentation = $estate->toArray();

Building

The Building class represents a specific building within an estate.

Property Type Description
id string Unique identifier
name ?string Name of the building
address ?Address Physical address of the building
area ?float Total area of the building in square meters
media Media Images, videos, and 3D scans related to the building
features array List of features and amenities specific to the building
rentables array List of Rentable spaces within the building

Usage:

$building = new Building(
    id: 'B1',
    name: 'Building 1',
    area: 1000.0,
    media: new Media()
);
$arrayRepresentation = $building->toArray();

Rentable

The Rentable class represents a space that can be rented or sold within a building.

Property Type Description
id string Unique identifier
name ?string Name of the rentable space
area ?float Area of the space in square meters
description ?string Detailed description of the space
transaction_type TransactionType Type of transaction (Rent or Sale)
price ?Price Pricing information for the space
spaces array List of Space objects within the rentable area
features array List of features and amenities specific to the rentable space
media Rentable\Media Images, videos, and 3D scans related to the rentable space

Usage:

$rentable = new Rentable(
    id: 'R1',
    name: 'Office Space 1',
    area: 100.0,
    transaction_type: TransactionType::Rent,
    price: new Price(
        base: new Money(1000.0, Currency::Euro)
    )
);
$arrayRepresentation = $rentable->toArray();

Location Models

Address

The Address class represents a physical address.

Property Type Description
street string Street name
number ?string Street number
postal_code ?string Postal code
city ?string City name
country ?string Country code
coordinates ?Coordinates Geographical coordinates of the address
label ?string Custom label for the address

Usage:

$address = new Address(
    street: 'Main St',
    number: '123',
    postal_code: '12345',
    city: 'Sample City',
    country: 'US'
);
$arrayRepresentation = $address->toArray();

Coordinates

The Coordinates class represents geographic coordinates.

Property Type Description
latitude float Latitude value
longitude float Longitude value

Usage:

$coordinates = new Coordinates(
    latitude: 40.7128,
    longitude: -74.0060
);
$arrayRepresentation = $coordinates->toArray();

Location

The Location class represents the location of an estate, including nearby places.

Property Type Description
places array List of nearby Place objects

Usage:

$location = new Location();
$location->places[] = new Place(
    type: Place\Type::from('restaurant'),
    name: 'Sample Restaurant',
    coordinates: new Coordinates(40.7128, -74.0060)
);
$arrayRepresentation = $location->toArray();

Media Models

Image

The Image class represents an image asset.

Property Type Description
src string Source URL of the image
alt ?string Alternative text for accessibility

Usage:

$image = new Image();
$image->src = 'https://example.com/image.jpg';
$image->alt = 'Sample Image';
$arrayRepresentation = $image->toArray();

Media

The Media class represents a collection of media assets for an estate.

Property Type Description
thumbnail ?Image Thumbnail image for the estate
gallery array Collection of Image objects
logo ?Image Logo image for the estate
videos array Collection of Video objects
scans array Collection of Scan objects

Usage:

$media = new Media();
$media->thumbnail = new Image();
$media->thumbnail->src = 'https://example.com/thumbnail.jpg';
$arrayRepresentation = $media->toArray();

Video

The Video class represents a video asset.

Property Type Description
id ?string Unique identifier for the video
type Video\Type Type of video (e.g., Embed, Direct)
thumbnail_url ?string URL of the video thumbnail image

Usage:

$video = new Video(
    type: Video\Type::Embed,
    thumbnail_url: 'https://example.com/video_thumbnail.jpg'
);
$arrayRepresentation = $video->toArray();

Scan

The Scan class represents a 3D scan or virtual tour.

Property Type Description
id ?string Unique identifier for the scan
type Scan\Type Type of scan (e.g., Embed)
provider ?string Name of the scan provider

Usage:

$scan = new Scan(
    type: Scan\Type::Embed,
    provider: 'Matterport'
);
$arrayRepresentation = $scan->toArray();

CameraFeed

The CameraFeed class represents a live camera feed.

Property Type Description
id ?string Unique identifier for the camera feed
type CameraFeed\Type Type of camera feed (e.g., Embed)
provider ?string Name of the camera feed provider

Usage:

$cameraFeed = new CameraFeed(
    type: CameraFeed\Type::Embed,
    provider: 'Sample Provider'
);
$arrayRepresentation = $cameraFeed->toArray();

Financial Models

Money

The Money class represents a monetary value.

Property Type Description
amount float Numeric amount
currency Currency Currency of the amount

Usage:

$money = new Money(
    amount: 1000.0,
    currency: Currency::Euro
);
$arrayRepresentation = $money->toArray();

Price

The Price class represents the price of a rentable space.

Property Type Description
base Money Base price
extra_costs ?Money Additional costs

Usage:

$price = new Price(
    base: new Money(1000.0, Currency::Euro),
    extra_costs: new Money(100.0, Currency::Euro)
);
$arrayRepresentation = $price->toArray();

Web Expose Models

WebExpose

The WebExpose class represents the structure for web-based property exposure.

Property Type Description
sidebar_features array Features to display in the sidebar
pool_features array Features to display in the pool section
blocks array List of content Block objects

Usage:

$webExpose = new WebExpose();
$webExpose->sidebar_features = ['feature1', 'feature2'];
$webExpose->blocks[] = new TextBlock('Sample text content');
$arrayRepresentation = $webExpose->toArray();

Block

The Block class is an abstract base class for various types of content blocks in the web expose.

Property Type Description
id ?string Unique identifier for the block
type BlockType Type of the content block

Usage (example with TextBlock):

$block = new TextBlock(
    text: 'Sample text content',
    id: 'block1'
);
$arrayRepresentation = $block->toArray();

Utility Models

Contact

The Contact class represents contact information.

Property Type Description
name string Name of the contact
role ?string Role or position of the contact
email ?string Email address
phone ?string Phone number
mobile ?string Mobile number
avatar ?Image Avatar image of the contact
address ?Address Physical address of the contact

Usage:

$contact = new Contact(
    name: 'John Doe',
    email: '[email protected]',
    phone: '+1234567890'
);
$arrayRepresentation = $contact->toArray();

Certifications

The Certifications class represents various certifications for an estate.

Property Type Description
dgnb ?DGNBCertification DGNB (German Sustainable Building Council) certification level
co2_neutral ?bool Indicates if the estate is CO2 neutral

Usage:

$certifications = new Certifications();
$certifications->dgnb = DGNBCertification::Gold;
$certifications->co2_neutral = true;
$arrayRepresentation = $certifications->toArray();