Skip to main content

Overview

Models are the foundation of Unleash Commerce, representing your business entities like products, orders, customers, and more. They extend Laravel’s Eloquent ORM and include built-in relationships and scopes.

Core Models

Unleash Commerce provides several core models out of the box:
  • Product: Represents items in your catalog
  • Order: Represents customer purchases
  • Customer: Represents your B2B customers
  • Category: Organizes products into logical groups

Extending Models

You can extend existing models by creating your own subclasses or by using the contract system to swap implementations.

Accessing the Primary Key

Always use $model->getKey() instead of directly referencing $model->id to ensure compatibility with custom primary key configurations.
$customerId = $customer->getKey();

Relationships

Models include pre-defined relationships to help you work with related data efficiently. Refer to the specific model documentation for relationship details.