Printable polymorphic relations
A PrintJob uses printable_id and printable_type to identify the entity being printed. The current API creation controller recognizes attendee credentials and social-stream posts. Other proposed types, such as agendas or certificates, require implementation; they are not available simply because the relationship is polymorphic.
Fetch a job and its printable
Use the project-scoped read operation:
GET /api/v1/projects/{teamSlug}/{projectSlug}/printing/print-jobs/{print_job}?include=printable.attendee
The current route registration has no ordinary job-list GET /print-jobs operation. For discovery, use POST /print-jobs/search under the same printing prefix and the REST API reference for its request shape. See Print server flow for creation, status updates and content operations.
The allowed includes are:
| Include | What the controller loads |
|---|---|
printable | The polymorphic entity, without explicitly adding its attendee relation |
printable.attendee | The printable and its attendee for the mapped types |
The controller handles these includes separately from Orion's ordinary relation loading. It removes paths beginning with printable from the parent relation list, then loads the requested supported path itself. The current morphWith map is:
return [
AttendeeCredential::class => ['attendee'],
SocialStreamPost::class => ['attendee'],
];
This avoids asking every possible printable model to implement the same nested relationship. It does not guarantee that future types have attendee data or that every downstream serialization path is free of extra queries.
Response boundaries
The job resource returns job fields such as ID, printable identity, access-point/project IDs, status, approval fields, metadata and timestamps. When the printable is loaded, it transforms credentials through AttendeeCredentialResource and social posts through SocialStreamPostResource. If the relation is loaded but absent, it returns null; without an include, the printable field is omitted by the resource's conditional loading.
Do not assume a generic hand-written attendee JSON shape applies to both printable types. Their resource transformers control which attendee and printable fields are emitted. Request nested attendee data only when needed and verify the actual principal's visibility.
The model's compatibility attendee_credential_id accessor returns the printable ID only when printable_type is AttendeeCredential::class. It is not a replacement for checking the printable type, and it is not a separate stored job foreign key.
Creation and rendering are separate
The create controller resolves the supplied attendee_credential_id or social_stream_post_id within the current project, then derives the morph fields. It strips client-supplied printable_id, printable_type and arbitrary metadata rather than accepting an unrestricted model class from the caller. If both recognized IDs reach the controller, the credential branch wins; supply one intended printable.
A job for a social post does not establish that the credential-only /preview, /html or /print endpoints can render it. Those operations accept attendee credential IDs. The installed print client must support the selected printable type and its content workflow.
Extend the platform with another printable type
This requires a platform code change and its authorization/rendering tests, not just a new API payload:
- Define the model and project ownership relationship. Add a
morphMany(PrintJob::class, 'printable')relationship where reverse job navigation is needed. - Add project-scoped validation to
PrintJob::createRules. Update cross-field required rules for existing printable IDs so exactly the intended selection behavior is documented and tested. - Add the new field to
PrintJobRequest::storeRulesandBATCH_STORE_ALLOWED_FIELDS. Model rules alone do not expose a field through the request whitelist. Check batch cross-field rule rewriting and the 1,000-item batch-job limit separately. - Add a controller resolution branch that verifies the entity belongs to the current project and derives its morph identity and server metadata. Keep server-owned fields protected.
- Extend
getPrintableMorphWithRelationsonly with relations actually supported by the new type. UpdatePrintJobResource's printable resource map with an intentional serializer; do not rely on the raw-model fallback to define a public contract. - Update broadcast payload handling in
BasePrintJobEvent, relevant authorization/data scopes, and the print client's supported content routing. A model relationship alone does not supply a renderer, approval UI or device integration. - Test creation and retrieval with the new type, wrong-project denial, includes with and without attendee data, batch handling, serialized fields, private broadcasts and rendering failures. Verify a controlled physical output before calling the feature supported.
Source reference and limits
Reviewed PrintJob, PrintJobController, PrintJobRequest, PrintJobResource and BasePrintJobEvent source on 2026-10-14. The mapped types and current include behavior are source contracts. End-to-end permissions, new-type support, deployed broadcasts and physical printing require acceptance testing.
See the relationship map and credential types guide for surrounding data and assignment behavior.