Skip to main content

Billable Models

A billable is any Eloquent model that can hold subscriptions. Typically this is your User model, but it can be any model — a Team, Organisation, or Project works equally well.

Setting up a billable model

Implement the Billable contract and add the ManagesBilling trait:
That’s it. The trait wires up all relationships and helper methods automatically.

Register the billable type

Add your billable class to config/subscribd.php under the billables key:
The key (user) is used internally when storing polymorphic relationships and in the Filament admin panel’s transfer action dropdown.

Multiple billable types

You can register as many billable types as your application needs:
Each model implements Billable and uses ManagesBilling independently.

Relationships

The ManagesBilling trait provides the following Eloquent relationships:

Subscription helpers

Invoice helpers

Payment method helpers

Billing identity

Subscribd reads these methods when communicating with gateways. Override them if your model uses different column names:
To use a different column or a computed value, override the method on your model:

Gateway customer IDs

Subscribd stores gateway customer IDs in a JSON column on your billable table. Run the migration published by vendor:publish --tag=subscribd-migrations to add this column, or add it manually:
To read or write a customer ID:
If you’re migrating from a setup that stored IDs in per-gateway columns (subscribd_stripe_id, etc.), the getter falls back to those columns automatically. Run php artisan subscribd:migrate-customer-ids to backfill the JSON column.

Next steps