Skip to main content
A billable is any Eloquent model that can own subscriptions, receive invoices, and be registered as a customer with a payment gateway. Subscribd ships a Billable contract and a ManagesBilling trait that you drop onto your model — no base class required. The most common case is User, but Team, Organization, or any other model works equally well.

Implementing the Billable contract

Add the Billable interface and the ManagesBilling trait to your model, then implement the two required methods that Subscribd uses to create gateway customers and generate invoices.
use Illuminate\Foundation\Auth\User as Authenticatable;
use Pixelworxio\Subscribd\Concerns\ManagesBilling;
use Pixelworxio\Subscribd\Contracts\Billable;

class User extends Authenticatable implements Billable
{
    use ManagesBilling;

    // Subscribd reads this to generate invoices and create gateway customers.
    public function billingEmail(): string
    {
        return $this->email;
    }

    public function billingName(): string
    {
        return $this->name;
    }
}
billingEmail() and billingName() are the only methods you must define. Everything else — subscription relationships, gateway customer lookups, invoice queries — is provided by ManagesBilling.

Supporting multiple billable types

You can register as many billable types as your application needs. Each key becomes a slug used internally to resolve the correct model class from a subscription record.
// config/subscribd.php
'billables' => [
    'user' => \App\Models\User::class,
    'team' => \App\Models\Team::class,
],
When billing teams, the Team model holds the subscription and the gateway customer record. Individual team members access features through entitlement checks on the team’s plan, not their own.

What ManagesBilling provides

The ManagesBilling trait wires up the following on your model automatically:
  • subscriptions() — Eloquent HasMany relationship to Subscription records
  • invoices — Eloquent relationship to all Invoice records for this billable
  • subscribed($name) — checks for an active or trialing subscription
  • onTrial($name) — checks whether the named subscription is in a trial period
  • onGracePeriod($name) — checks whether a canceled subscription is still within its grace period
The trait does not add any database columns to your model’s own table. All subscription data is stored in Subscribd’s own tables using a polymorphic relationship keyed by the billable type and ID.

Next steps

Once your model is billable, create plans in config and subscribe users to them: