[WIP] Update
This commit is contained in:
@@ -122,6 +122,17 @@ class Claim extends Model
|
||||
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
// Current ClaimRequest that refer to the claim
|
||||
public function claimRequest()
|
||||
{
|
||||
return $this->belongsTo(ClaimRequest::class, 'claim_request_id');
|
||||
}
|
||||
|
||||
// Possibilities of ClaimRequest that refer to the claim
|
||||
public function claimRequests()
|
||||
{
|
||||
return $this->hasMany(ClaimRequest::class, 'claim_id');
|
||||
}
|
||||
|
||||
public function files()
|
||||
{
|
||||
|
||||
@@ -17,8 +17,12 @@ class ClaimRequest extends Model
|
||||
protected static $code_prefix = 'CRQ';
|
||||
|
||||
public $fillable = [
|
||||
'uuid',
|
||||
'submission_date',
|
||||
'member_id',
|
||||
'payment_type',
|
||||
'service_code',
|
||||
'policy_id',
|
||||
'status',
|
||||
'claim_id'
|
||||
];
|
||||
@@ -35,13 +39,19 @@ class ClaimRequest extends Model
|
||||
public static $status = [
|
||||
'draft' => 'Draft',
|
||||
'requested' => 'Requested',
|
||||
'received' => 'Received',
|
||||
'approved' => 'Approved',
|
||||
'postpone' => 'Postpone',
|
||||
'paid' => 'Paid',
|
||||
'declined' => 'Declined'
|
||||
];
|
||||
|
||||
public static $payment_types = [
|
||||
'cashless' => 'Cashless',
|
||||
'reimbursement' => 'Reimbursement'
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'payment_type_name'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
@@ -116,6 +126,11 @@ class ClaimRequest extends Model
|
||||
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function claim()
|
||||
{
|
||||
return $this->belongsTo(Claim::class, 'claim_id');
|
||||
}
|
||||
|
||||
public function claims()
|
||||
{
|
||||
return $this->hasMany(Claim::class, 'claim_request_id');
|
||||
@@ -140,4 +155,19 @@ class ClaimRequest extends Model
|
||||
{
|
||||
return $this->belongsTo(Member::class, 'member_id', 'id');
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class, 'service_code', 'code');
|
||||
}
|
||||
|
||||
public function getPaymentTypeNameAttribute()
|
||||
{
|
||||
return self::$payment_types[$this->payment_type] ?? $this->payment_type;
|
||||
}
|
||||
|
||||
public function getStatusAttribute($value)
|
||||
{
|
||||
return self::$payment_types[$value] ?? $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,13 +151,20 @@ class Member extends Model
|
||||
}
|
||||
|
||||
public function currentPolicy()
|
||||
{
|
||||
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
|
||||
->where('status', 'active')
|
||||
->orderBy('end', 'DESC');
|
||||
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
||||
}
|
||||
|
||||
public function currentActivePolicy()
|
||||
{
|
||||
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
|
||||
->where('corporate_policies.start', '<', now())
|
||||
->where('corporate_policies.end', '>', now())
|
||||
->where('member_policies.start', '<', now())
|
||||
->where('member_policies.end', '>', now());
|
||||
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
||||
}
|
||||
|
||||
public function getAgeAttribute()
|
||||
|
||||
Reference in New Issue
Block a user