|
@@ -20,7 +20,7 @@ class Client extends Model
|
|
|
->orderBy('created_at', 'desc');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
public function latestManualParentClientPrimaryCoverage(){
|
|
|
return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_manual_parent_client_primary_coverage_id');
|
|
|
}
|
|
@@ -180,7 +180,7 @@ class Client extends Model
|
|
|
return $this->hasOne(AppSession::class, 'id', 'sticky_note_updated_by_session_id');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public function creator()
|
|
|
{
|
|
@@ -277,6 +277,13 @@ class Client extends Model
|
|
|
->orderBy('created_at', 'asc');
|
|
|
}
|
|
|
|
|
|
+ public function companyClients()
|
|
|
+ {
|
|
|
+ return $this->hasMany(CompanyClient::class, 'client_id', 'id')
|
|
|
+ ->where('is_active', true)
|
|
|
+ ->orderBy('created_at', 'asc');
|
|
|
+ }
|
|
|
+
|
|
|
public function handouts($note = null)
|
|
|
{
|
|
|
$mappings = HandoutClient::where('client_id', $this->id);
|
|
@@ -390,7 +397,7 @@ class Client extends Model
|
|
|
public function previousCareMonth()
|
|
|
{
|
|
|
$cmStartDate = date('Y-m-d', strtotime('first day of last month'));
|
|
|
-
|
|
|
+
|
|
|
return CareMonth
|
|
|
::where('client_id', $this->id)
|
|
|
->where('start_date', $cmStartDate)
|
|
@@ -1029,7 +1036,7 @@ ORDER BY m.ts DESC
|
|
|
->orderBy('created_at', 'desc');
|
|
|
}
|
|
|
|
|
|
- public function mostRecentWeightMeasurement(){
|
|
|
+ public function mostRecentWeightMeasurement(){
|
|
|
return $this->hasOne(Measurement::class, 'id', 'most_recent_weight_measurement_id');
|
|
|
}
|
|
|
|
|
@@ -1053,13 +1060,13 @@ ORDER BY m.ts DESC
|
|
|
}
|
|
|
|
|
|
public function clientBpWeightPhoneNumberStatus(){
|
|
|
- return $this->hasOne(ClientBpWeightPhoneNumberStatus::class, 'id', 'client_bp_weight_phone_number_status_id');
|
|
|
+ return $this->hasOne(ClientBpWeightPhoneNumberStatus::class, 'id', 'client_bp_weight_phone_number_status_id');
|
|
|
}
|
|
|
|
|
|
public function getDeviceDeliveryStatus($productId){
|
|
|
$result = DB::select("SELECT sh.status FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id WHERE so.product_id = ".$productId." AND so.client_id = ".$this->id." ORDER BY sh.created_at DESC LIMIT 1");
|
|
|
if (count($result)){
|
|
|
- return $result[0]->status;
|
|
|
+ return $result[0]->status;
|
|
|
}
|
|
|
return '';
|
|
|
}
|
|
@@ -1094,7 +1101,7 @@ ORDER BY m.ts DESC
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 4 Infra-red Temperature gun
|
|
|
+ // 4 Infra-red Temperature gun
|
|
|
public function temparatureGunDeliveryStatus(){
|
|
|
return $this->getDeviceDeliveryStatus(4);
|
|
|
}
|
|
@@ -1107,7 +1114,7 @@ ORDER BY m.ts DESC
|
|
|
public function cellularBPDeliveryStatus(){
|
|
|
return $this->getDeviceDeliveryStatus(1);
|
|
|
}
|
|
|
- // 2 Weight scale
|
|
|
+ // 2 Weight scale
|
|
|
public function weightScaleDeliveryStatus(){
|
|
|
return $this->getDeviceDeliveryStatus(2);
|
|
|
}
|