Skip to content

Models

All models live in the Integrations\Models namespace.

Integration

The central model. Represents a configured connection to an external service.

Relationships

RelationshipTypeTarget
requests()hasManyIntegrationRequest
logs()hasManyIntegrationLog
mappings()hasManyIntegrationMapping
webhooks()hasManyIntegrationWebhook
syncItems()hasManyIntegrationSyncItem
incidents()hasManyIntegrationIncident
owner()morphToPolymorphic (Team, User, etc.)

Methods

MethodDescription
at($endpoint)Open the fluent request builder. Chain ->as(SomeData::class) to type the response.
request()Lower-level direct API request entry point (the builder funnels into this).
currentContext()Static. Read the active RequestContext from inside a closure when the closure can't take it as an argument. See Making requests.
currentSyncAttempt()Static. Read the active SyncAttemptContext from inside a sync-item listener. null outside a sync item. See terminal-vs-transient failures.
logOperation()Create an operation log entry
failureSummary($since)Failure report (per-operation counts, rate, last error, per-status / per-FailureClass breakdowns) over a window. See Failure summary.
incidents()The integration's incident history relation. The current_incident (?IntegrationIncident) and has_open_incident (bool) accessors read the loaded collection.
mapExternalId()Map an external ID to an internal model
resolveMapping()Resolve external ID to internal model (returns typed TModel)
resolveMappings()Batch-resolve multiple external IDs in two queries
upsertByExternalId()Resolve, create-or-update, and map in one call
findExternalId()Find external ID for an internal model
getAccessToken()Get OAuth access token (auto-refreshes)
tokenExpiresSoon()Check if token needs refresh
refreshTokenIfNeeded()Explicitly refresh token
markSynced()Update sync timestamps
recordSuccess()Record a successful request
recordFailure()Record a failed request
credentialsArray()Get raw credentials array
pendingSyncItemCount()Count of sync items still in flight (pending or processing)

Query scopes

ScopeDescription
ownedBy($model)Filter by polymorphic owner

IntegrationRequest

Represents a single API request/response.

Relationships

RelationshipTypeTarget
integration()belongsToIntegration
related()morphToPolymorphic (linked model)
retryOf()belongsToIntegrationRequest (original attempt)

Notable properties

PropertyTypeDescription
idempotency_key?stringIdempotency key, if one was set via withIdempotencyKey(). See Idempotency.
provider_request_id?stringUpstream's request ID (e.g. Stripe Request-Id, GitHub X-GitHub-Request-Id). Populated by adapter closures via RequestContext::reportResponseMetadata(). Useful when filing support tickets against the provider.
failure_class?FailureClassThe classified failure on the failure path; null on success. See What counts as a failure.

Query scopes

ScopeDescription
successful() / failed()Filter by response_success
forEndpoint($endpoint)Filter by endpoint
withFailureClass($class)Filter by persisted FailureClass
recent($hours) / since($since)Created within the last N hours / at or after a CarbonInterface

Testing methods

MethodDescription
fake()Activate the testing fake
stopFaking()Deactivate the testing fake
assertRequested()Assert an endpoint was called
assertNotRequested()Assert an endpoint was not called
assertRequestedWith()Assert with custom assertion
assertRequestCount()Assert total request count
assertNothingRequested()Assert no requests were made

IntegrationLog

Represents an operation-level log entry (sync, import, webhook processing).

Relationships

RelationshipTypeTarget
integration()belongsToIntegration
parent()belongsToIntegrationLog
children()hasManyIntegrationLog

Query scopes

ScopeDescription
successful()Where status is success
failed()Where status is failed
forOperation($op)Filter by operation type
topLevel()Where parent_id is null
recent($hours)Created within the last N hours
since($since)Created at or after a CarbonInterface

Status constants

STATUS_SUCCESS, STATUS_FAILED, STATUS_PROCESSING, STATUS_PARTIAL, STATUS_DEFERRED. The documented status vocabulary; the column stays a free string. Only success / failed / processing dispatch events; partial (a sync run with some failed items) and deferred are recorded silently.

IntegrationMapping

Maps external provider IDs to internal Eloquent models.

Relationships

RelationshipTypeTarget
integration()belongsToIntegration
internal()morphToPolymorphic (mapped model)

IntegrationWebhook

Stores received webhook payloads for audit and replay.

Relationships

RelationshipTypeTarget
integration()belongsToIntegration

IntegrationSyncItem

One row per item dispatched during a sync run. The framework uses these to track per-item completion and decide when the cursor can advance. See Scheduled syncs.

Relationships

RelationshipTypeTarget
integration()belongsToIntegration
syncLog()belongsToIntegrationLog

Methods

MethodDescription
isTerminal()Whether the item reached a terminal state (success, failed, or skipped)

Query scopes

ScopeDescription
pending() / processing() / successful() / failed() / skipped()Filter by status
inFlight()Items not yet terminal (pending or processing)
forBatch($batchId)Items in a Bus batch
forSyncLog($syncLogId)Items belonging to one sync run
forIntegration($integrationId)Items for one integration

Status constants

STATUS_PENDING, STATUS_PROCESSING, STATUS_SUCCESS, STATUS_FAILED, STATUS_SKIPPED.

IntegrationIncident

A durable record of one period an integration was in trouble, written from health/circuit state-change events. See Incident history.

Relationships

RelationshipTypeTarget
integration()belongsToIntegration

Methods

MethodDescription
isOpen()Whether the incident is still open

Query scopes

ScopeDescription
open() / closed()Filter by status
forIntegration($id)Incidents for one integration
since($since)Opened at or after a CarbonInterface

Constants

STATUS_OPEN, STATUS_CLOSED, SOURCE_HEALTH, SOURCE_CIRCUIT.