Use this file to discover all available pages before exploring further.
The Billable trait is the single entry point to everything Laravel Polar does. Add it to any Eloquent model and that model gains the ability to create checkout sessions, manage subscriptions, retrieve orders, work with license keys, track usage events, and more — all through expressive, chainable PHP methods.
Think of Billable like Laravel Cashier’s trait: one line of code turns any model into a full billing entity. Unlike Cashier, it’s not limited to User — add it to Team, Organization, or any other billable entity in your app.
Import Danestves\LaravelPolar\Billable and add it to your model:
use Danestves\LaravelPolar\Billable;use Illuminate\Foundation\Auth\User as Authenticatable;class User extends Authenticatable{ use Billable;}
The trait can be added to any Eloquent model, not only User. If your application bills teams, organisations, or companies, add Billable to those models instead — or in addition.
use Danestves\LaravelPolar\Billable;use Illuminate\Database\Eloquent\Model;class Team extends Model{ use Billable;}
By default the trait reads two attributes from the model when creating customer records and prefilling checkout forms:
Attribute
Used for
name
Customer display name sent to Polar
email
Customer email address sent to Polar
If your model uses different attribute names, or you want to derive these values differently, override either method:
class User extends Authenticatable{ use Billable; public function polarName(): ?string { return $this->full_name; // use a different attribute } public function polarEmail(): ?string { return $this->billing_email ?? $this->email; }}
The Billable trait is composed of eight focused sub-traits. Here’s a summary of every method each one adds — useful as a quick reference when writing code or asking an AI assistant for help:
By default the package uses its own Customer, Subscription, and Order Eloquent models. You can swap in your own — useful when you need to add custom attributes, relationships, or scopes — by calling the appropriate method on the LaravelPolar facade in a service provider’s boot method:
use Danestves\LaravelPolar\LaravelPolar;public function boot(): void{ LaravelPolar::useCustomerModel(\App\Models\PolarCustomer::class); LaravelPolar::useSubscriptionModel(\App\Models\PolarSubscription::class); LaravelPolar::useOrderModel(\App\Models\PolarOrder::class);}
Your custom models should extend the package’s base models (Danestves\LaravelPolar\Customer, Danestves\LaravelPolar\Subscription, or Danestves\LaravelPolar\Order) so all existing relationships and methods continue to work.
All three use*Model methods are optional. Override only the models you need to customise — the rest will continue using the package defaults.