SurrealDB relation tables are represented by edge models. An edge model maps to a relation table and declares the models on each end, so traversals and RELATE statements are checked against your types.
Edge models
An edge model extends Surqlize\Edge\Edge and uses the #[Edge] attribute with the relation table name and the in and out endpoint models.
Edge models inherit RecordId $in and RecordId $out endpoint properties from Surqlize\Edge\Edge.
Traversing in a SELECT
Use graph fields inside a model SELECT to traverse relations. Edge::out() and Edge::in() start a traversal in the given direction; chain another out() or in() to reach the far table, optionally with a predicate, then name it with as() and resolve it with fetch().
Edge::out() is a magic static call. If your static analysis setup struggles with it, use the explicit factory.
Querying an edge's endpoints
An edge instance can query its endpoint tables with in() and out(), which return model queries.
Creating relations
Model::relate($from) starts a RELATE. Chain edge() with the edge class, with() for the target, and content() for data on the edge.
Both endpoint models must already have RecordId values. The builder validates that the source matches the edge's in endpoint and the target matches the out endpoint. Use set($key, $value) for a single field, and compile() or toSdkQuery() to inspect the statement instead of running it.