Keep track of discontinued items. That means items that were tracked, but then they were never updated.Added is discontinued badge.

This commit is contained in:
Krzysztof Płaczek
2025-02-15 11:33:24 +01:00
parent 7eb7bf3eb2
commit 81f9c863c7
7 changed files with 52 additions and 9 deletions

View File

@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use function Symfony\Component\Clock\now;
/**
* @property integer $skuID
* @property string $name
@@ -66,9 +68,12 @@ class Product extends Model
);
}
public function isnew(): bool
public function isDiscontinued(): bool
{
$newDate = (new \DateTime())->modify('-30 days')->format('Y-m-d');
return $this->created_at->format('Y-m-d') > $newDate;
return $this->updated_at->format('Y-m-d') < now()->format('Y-m-d');
}
public function isNew(): bool
{
return $this->created_at->format('Y-m-d') > now()->modify('-30 days')->format('Y-m-d');
}
}