where('status', 'approved') ->where('created_at', '<', self::collectionMethodReleaseDate()) ->exists(); return !$approvedBeforeRelease; } /** * True when a charge should be folded into the loan principal for this * application. Applies the release gate, so "added in loan amount" can never * take effect on an application approved before the release date. * * @param int|string|null $method * @param int|null $applicationId * @return bool */ public static function isAddedInLoanAmountForApplication($method, $applicationId) { return self::isAddedInLoanAmount($method) && self::collectionMethodsApply($applicationId); } /** * Guards a collection method before it is persisted. * * "Added in loan amount" is not available on applications approved before the * release date, so the value is refused for those. Returning null tells the * caller to leave the stored value untouched rather than silently substituting * a different collection method, which would move money. * * @param int|string|null $method * @param int|null $applicationId * @return int|null the value to persist, or null to skip the write */ public static function collectionMethodForPersistence($method, $applicationId) { if (is_null($method) || $method === '') { return null; } if (self::isAddedInLoanAmount($method) && !self::collectionMethodsApply($applicationId)) { return null; } return (int) $method; } public function consumner(){ return $this->hasOne('App\ConsumerApplication','id','application_id'); } public function fldg_category(){ return $this->hasOne('App\FLDGCategory','id','fldg_applied_category'); } }