Member Model
Extended user profile with carrier-specific information and medical/pharmaceutical details.
Overview
The Member model extends the User model with carrier-specific information, medical details, and pharmaceutical requirements. It serves as the bridge between users and carriers in the multi-tenant system.
Attributes
| Attribute | Type | Description |
|---|---|---|
id | int | Primary key |
user_id | int | Foreign key to User |
carrier_id | int | Foreign key to Carrier |
phone | string | Contact phone number |
date_of_birth | date | Member's date of birth |
address | string | Street address |
city | string | City |
state | string | State/province |
zip_code | string | Postal code |
is_active | boolean | Active status flag |
metadata | json | Additional JSON data |
created_at | timestamp | Creation timestamp |
updated_at | timestamp | Last update timestamp |
deleted_at | timestamp | Soft delete timestamp |
Relationships
Belongs To
belongsTo(User)- Associated user accountbelongsTo(Carrier)- Associated carrier
Has Many
hasMany(Cart)- Member's shopping cartshasMany(Order)- Member's orders
Key Features
Multi-Tenancy
- Belongs to a specific carrier
- Carrier-specific data isolation
- Multi-tenant member management
Medical Information
- Date of birth tracking
- Contact information management
- Address storage and validation
Search Integration
- MeiliSearch integration for full-text search
- Searchable member profiles
- Fast member lookup
Data Management
- Soft deletes for data retention
- Active member scope filtering
- Flexible metadata storage
Usage Examples
Creating a Member
php
$member = Member::create([
'user_id' => $user->id,
'carrier_id' => $carrier->id,
'phone' => '+1234567890',
'date_of_birth' => '1990-01-01',
'address' => '123 Main St',
'city' => 'Anytown',
'state' => 'CA',
'zip_code' => '12345',
'is_active' => true,
'metadata' => [
'emergency_contact' => 'Jane Doe',
'medical_conditions' => ['diabetes', 'hypertension']
]
]);Getting Associated Data
php
// Get user account
$user = $member->user;
// Get carrier
$carrier = $member->carrier;
// Get member's carts
$carts = $member->carts;
// Get member's orders
$orders = $member->orders;Searching Members
php
// Search by name or email
$members = Member::search('john doe')->get();
// Get active members
$activeMembers = Member::active()->get();
// Get members by carrier
$carrierMembers = Member::where('carrier_id', $carrierId)->get();Scopes
Active Members
php
// Get only active members
Member::active()->get();By Carrier
php
// Get members for specific carrier
Member::where('carrier_id', $carrierId)->get();Accessors
Email Accessor
php
// Get member's email through user relationship
$email = $member->email; // Returns $member->user->email