|
@@ -16,6 +16,7 @@ class Client extends Model
|
|
|
public function primaryCoverages()
|
|
|
{
|
|
|
return $this->hasMany(ClientPrimaryCoverage::class, 'client_id', 'id')
|
|
|
+ ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)')
|
|
|
->orderBy('created_at', 'desc');
|
|
|
}
|
|
|
|
|
@@ -26,10 +27,12 @@ class Client extends Model
|
|
|
return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_new_client_primary_coverage_id');
|
|
|
}
|
|
|
public function latestAutoRefreshClientPrimaryCoverage(){
|
|
|
- return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_auto_refresh_client_primary_coverage_id');
|
|
|
+ return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_auto_refresh_client_primary_coverage_id')
|
|
|
+ ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)');
|
|
|
}
|
|
|
public function latestManualClientPrimaryCoverage(){
|
|
|
- return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_manual_client_primary_coverage_id');
|
|
|
+ return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'latest_manual_client_primary_coverage_id')
|
|
|
+ ->whereRaw('(is_cancelled IS NULL OR is_cancelled IS FALSE)');
|
|
|
}
|
|
|
public function temporaryOutsiderNewClientPrimaryCoverage(){
|
|
|
return $this->hasOne(ClientPrimaryCoverage::class, 'id', 'temporary_outsider_new_client_primary_coverage_id');
|
|
@@ -886,7 +889,12 @@ ORDER BY m.ts DESC
|
|
|
|
|
|
public function getPrimaryCoverage()
|
|
|
{
|
|
|
- $coverage = $this->latestClientPrimaryCoverage;
|
|
|
+ // try the latest manual coverage
|
|
|
+ $coverage = $this->latestManualClientPrimaryCoverage;
|
|
|
+ if (!$coverage) {
|
|
|
+ // try the latest auto coverage
|
|
|
+ $coverage = $this->latestAutoRefreshClientPrimaryCoverage;
|
|
|
+ }
|
|
|
return $coverage;
|
|
|
}
|
|
|
|