Carrier Model
Multi-tenant carrier/organization that manages members and products.
Overview
The Carrier model is the central entity in the multi-tenant system, representing organizations that manage members, products, and shopping carts. Each carrier operates independently with their own data isolation.
Attributes
| Attribute | Type | Description |
|---|---|---|
id | int | Primary key |
name | string | Carrier name |
slug | string | URL-friendly identifier |
domain | string | Carrier domain |
description | text | Carrier description |
logo_url | string | Logo image URL |
is_active | boolean | Active status flag |
settings | json | JSON configuration settings |
created_at | timestamp | Creation timestamp |
updated_at | timestamp | Last update timestamp |
deleted_at | timestamp | Soft delete timestamp |
Relationships
Has Many
hasMany(Member)- Carrier's membershasMany(Cart)- Carrier's shopping cartshasMany(Order)- Carrier's orders
Key Features
Multi-Tenancy
- Central multi-tenant entity
- Data isolation between carriers
- Independent carrier operations
Branding & Customization
- Custom domain support
- Logo and branding management
- Carrier-specific settings
Search Integration
- MeiliSearch integration for name and slug search
- Fast carrier lookup
- Searchable carrier profiles
Data Management
- Soft deletes for data retention
- Active carrier scope filtering
- Flexible settings storage
Usage Examples
Creating a Carrier
php
$carrier = Carrier::create([
'name' => 'ABC Health Insurance',
'slug' => 'abc-health',
'domain' => 'abc.otcplatform.com',
'description' => 'Leading health insurance provider',
'logo_url' => 'https://example.com/logo.png',
'is_active' => true,
'settings' => [
'prescription_required' => true,
'max_cart_items' => 50,
'shipping_enabled' => true
]
]);Getting Associated Data
php
// Get carrier's members
$members = $carrier->members;
// Get carrier's carts
$carts = $carrier->carts;
// Get carrier's orders
$orders = $carrier->orders;
// Get active members
$activeMembers = $carrier->members()->active()->get();Searching Carriers
php
// Search by name or slug
$carriers = Carrier::search('health insurance')->get();
// Get active carriers
$activeCarriers = Carrier::active()->get();
// Get carrier by slug
$carrier = Carrier::where('slug', 'abc-health')->first();Scopes
Active Carriers
php
// Get only active carriers
Carrier::active()->get();By Domain
php
// Get carrier by domain
Carrier::where('domain', $domain)->first();Route Key
The Carrier model uses the slug as the route key for URL-friendly routing:
php
// Route model binding uses slug
Route::get('/carriers/{carrier}', function (Carrier $carrier) {
return $carrier;
});Settings Management
Carriers can store custom settings as JSON:
php
// Set carrier settings
$carrier->settings = [
'prescription_required' => true,
'max_cart_items' => 50,
'shipping_enabled' => true,
'tax_rate' => 0.08
];
$carrier->save();
// Get specific setting
$maxItems = $carrier->settings['max_cart_items'] ?? 25;