Skip to content

Referral ​

Represents a commission event generated when a referred visitor completes a qualifying action.

Table: fa_referrals
Class: FluentAffiliate\\App\\Models\\Referral.php

Columns ​

ColumnTypeNullableDefaultDescription
idBIGINT(20)NO—Primary key, auto-increment.
affiliate_idBIGINT(20)YES—Affiliate who earned this referral.
parent_idBIGINT(20)YES—Parent referral ID (for multi-tier, reserved).
customer_idBIGINT(20)YES—Customer record associated with this purchase.
visit_idBIGINT(20)YES—Visit that initiated this referral (if known).
descriptionLONGTEXTYES—Free-text description.
statusVARCHAR(100)YESpendingRecord status.
amountDOUBLEYESNULLCommission amount earned by the affiliate.
order_totalDOUBLEYESNULLTotal order value that generated the referral.
currencyCHAR(3)YES—ISO 4217 currency code (e.g. USD).
utm_campaignVARCHAR(100)YES—UTM campaign parameter from the tracking URL.
providerVARCHAR(100)YES—Integration slug that created this referral (e.g. woo, fluentcart).
provider_idBIGINT(20)YES—Provider-specific order/payment numeric ID.
provider_sub_idVARCHAR(192)YES—Provider-specific sub-ID (e.g. subscription ID).
productsLONGTEXTYES—JSON list of product IDs in the order.
payout_transaction_idBIGINT(20)YES—Payout transaction that included this referral.
payout_idBIGINT(20)YES—Parent payout record.
typeVARCHAR(100)YESsaleReferral type — sale, opt_in, or recurring_sale.
settingsLONGTEXTYES—Serialized JSON settings blob.
created_atTIMESTAMPYES—Timestamp when the record was created.
updated_atTIMESTAMPYES—Timestamp when the record was last updated.

Relationships ​

MethodTypeTargetDescription
affiliate()belongsToAffiliateAffiliate who earned this referral.
customer()belongsToCustomerCustomer who made the purchase.
visit()belongsToVisitClick-through visit that led to this referral.
payout()belongsToPayoutPayout batch that paid this referral.
transaction()belongsToTransactionPayout transaction record.

Query Scopes ​

ScopeDescription
ofStatus($status)Filter by status.
searchBy($search)Search across description and provider fields.
filterByAffiliate($id)Restrict to a specific affiliate.

Usage Example ​

php
use FluentAffiliate\App\Models\Referral;

$unpaid = Referral::ofStatus('unpaid')
    ->where('affiliate_id', $affiliateId)
    ->sum('amount');

FluentAffiliate developer documentation