Skip to main content
Customers are users who have the customer role and can place orders in your store. Shopper extends your Laravel User model with e-commerce specific fields and relationships.

User Model Integration

Shopper doesn’t create a separate Customer model. Instead, it extends your existing App\Models\User model with the InteractsWithShopper trait and ShopperUser contract.
The InteractsWithShopper trait provides:
  • HasRoles (Spatie Permission) for role-based access control
  • HasDiscounts for customer-specific discount eligibility
  • HasProfilePhoto for avatar management

Database Schema

User Table Modifications

Shopper modifies the standard Laravel users table:

Address Table

Gender Type

The GenderType enum defines available gender options:

Address Type

The AddressType enum defines address categories:

Relationships

Orders

Addresses

Query Scopes

Role Checking

Computed Attributes

Address Model

The model used is Shopper\Core\Models\Address. It implements Shopper\Core\Models\Contracts\Address and is configurable via config/shopper/models.php.

Extending the Address Model

Update config/shopper/models.php:

Address Relationships

Each address belongs to a user and optionally to a country:

Address Methods

The Address model provides helpers for checking default status:

Creating Customers

Basic Customer

Customer with Address

Retrieving Customers

Managing Addresses

Observer Behavior

When a user is deleted, the InteractsWithShopper trait automatically:
  • Detaches all roles
  • Deletes all addresses

Role Configuration

Roles are defined in config/shopper/admin.php:

Permissions

The admin panel generates five permissions for customer management:

Components

To customize the admin UI for customer management:
Creates config/shopper/components/customer.php:

Storefront Example

Use Cases