Adds default values if the expiring alerts threshold is null

This commit is contained in:
Ivan Nieto Vivanco 2022-01-18 14:21:49 -06:00
parent 201b52baf8
commit 42d86bf57b
2 changed files with 5 additions and 2 deletions

View file

@ -665,13 +665,15 @@ class Asset extends Depreciable
*/
public static function getExpiringWarrantee($days = 30)
{
$days = (is_null($days)) ? 30 : $days;
return Asset::where('archived', '=', '0')
->whereNotNull('warranty_months')
->whereNotNull('purchase_date')
->whereNull('deleted_at')
->whereRaw(\DB::raw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
. $days
. ' DAY) AND DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) > NOW()'))
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()'))
->orderBy('purchase_date', 'ASC')
->get();
}

View file

@ -627,7 +627,8 @@ class License extends Depreciable
*/
public static function getExpiringLicenses($days = 60)
{
$days = (is_null($days)) ? 30 : $days;
return License::whereNotNull('expiration_date')
->whereNull('deleted_at')
->whereRaw(DB::raw('DATE_SUB(`expiration_date`,INTERVAL '.$days.' DAY) <= DATE(NOW()) '))