User Model Integration
Shopper doesn’t create a separate Customer model. Instead, it extends your existingApp\Models\User model with the InteractsWithShopper trait and ShopperUser contract.
InteractsWithShopper trait provides:
HasRoles(Spatie Permission) for role-based access controlHasDiscountsfor customer-specific discount eligibilityHasProfilePhotofor avatar management
Database Schema
User Table Modifications
Shopper modifies the standard Laravelusers table:
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint | no | auto | Primary key |
first_name | string | yes | null | First name |
last_name | string | no | - | Last name |
email | string | no | - | Email address (unique) |
password | string | yes | null | Password (nullable for social auth) |
email_verified_at | timestamp | yes | null | Email verification date |
gender | string | yes | null | Gender enum value |
phone_number | string | yes | null | Phone number |
birth_date | date | yes | null | Birth date |
avatar_type | string | no | avatar_ui | Avatar source type |
avatar_location | string | yes | null | Avatar file path |
timezone | string | yes | null | User timezone |
opt_in | boolean | no | false | Marketing email consent |
last_login_at | timestamp | yes | null | Last login timestamp |
last_login_ip | string | yes | null | Last login IP address |
Address Table
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint | no | auto | Primary key |
first_name | string | no | - | First name |
last_name | string | no | - | Last name |
company_name | string | yes | null | Company name |
street_address | string | no | - | Street address |
street_address_plus | string | yes | null | Additional address line |
postal_code | string | no | - | Postal/ZIP code |
city | string | no | - | City |
state | string | yes | null | State/province/region |
phone_number | string | yes | null | Phone number |
shipping_default | boolean | no | false | Default shipping address |
billing_default | boolean | no | false | Default billing address |
type | string | yes | null | Address type enum |
country_id | bigint | yes | null | FK to countries |
user_id | bigint | no | - | FK to users |
Gender Type
TheGenderType enum defines available gender options:
Address Type
TheAddressType enum defines address categories:
Relationships
Orders
Addresses
Query Scopes
Role Checking
Computed Attributes
Address Model
The model used isShopper\Core\Models\Address. It implements Shopper\Core\Models\Contracts\Address and is configurable via config/shopper/models.php.
Extending the Address Model
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, theInteractsWithShopper trait automatically:
- Detaches all roles
- Deletes all addresses
Role Configuration
Roles are defined inconfig/shopper/admin.php:
Permissions
The admin panel generates five permissions for customer management:| Permission | Description |
|---|---|
browse_customers | View the customers list |
read_customers | View a single customer profile |
add_customers | Create new customers |
edit_customers | Edit customer profiles |
delete_customers | Delete or anonymize customers |
Components
To customize the admin UI for customer management:config/shopper/components/customer.php:
Storefront Example
Use Cases
| Scope | Description |
|---|---|
customers() | Users with ‘user’ role |
administrators() | Users with ‘admin’ or ‘manager’ role |
| Method | Description |
|---|---|
isAdmin() | Check if user has admin role |
isManager() | Check if user has manager role |
isVerified() | Check if email is verified |