Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
1
Indexable
Never
/**
     *
     * @return int
     */
    public static function getAssetAge($purchaseDate)
    {
        $dateNow = new DateTime();
        $datePurchase = new DateTime($purchaseDate);

        return $dateNow->diff($datePurchase)->days;
    }

    /**
     *
     * @return int
     */
    public static function validReport($purchaseDate, $expiryDate)
    {
        $purchaseDate = new DateTime($purchaseDate);
        $expiryDate = new DateTime($expiryDate);

        return $purchaseDate->diff($expiryDate)->days;
    }

    /**
     *
     * @return string
     */
    public static function getDamageDate($expiryDate, $remainingLife)
    {
        $damageDate = Carbon::createFromFormat('Y-m-d',$expiryDate);
        $damageDate = Carbon::parse($damageDate)->addDays($remainingLife);

        return $damageDate->toDateString();
    }

    /**
     *
     * @return string
     */
    public static function addExpiryDate($purchaseDate, $usefulLife)
    {
        $damageDate = Carbon::parse($purchaseDate)->addDays($usefulLife);

        return $damageDate->toDateString();
    }