Add new badge. Update screenshot.
This commit is contained in:
@@ -9,10 +9,11 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class NewController extends BaseController
|
||||
{
|
||||
#[Route('/promos', name: 'app_new')]
|
||||
#[Route('/new', name: 'app_new')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
$products = Product::whereHas('created_at', now()->subDays(30)->format('Y-m-d'))
|
||||
$date = (new \DateTime())->modify('-30 days')->format('Y-m-d');
|
||||
$products = Product::where('created_at', '>', $date)
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->with(['currentPrice'])
|
||||
|
||||
@@ -31,7 +31,7 @@ class Product extends Model
|
||||
|
||||
public function isStarred(): bool
|
||||
{
|
||||
return (bool) $this->starred;
|
||||
return (bool)$this->starred;
|
||||
}
|
||||
|
||||
public function currentPrice(): HasOne
|
||||
@@ -65,4 +65,10 @@ class Product extends Model
|
||||
set: fn(array $value) => json_encode($value),
|
||||
);
|
||||
}
|
||||
|
||||
public function isnew(): bool
|
||||
{
|
||||
$newDate = (new \DateTime())->modify('-30 days')->format('Y-m-d');
|
||||
return $this->created_at->format('Y-m-d') > $newDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ class AppExtension extends AbstractExtension
|
||||
|
||||
public function newCount(): int
|
||||
{
|
||||
return Product::whereHas('created_at', now()->subDays(30)->format('Y-m-d'))->count();
|
||||
$date = (new \DateTime())->modify('-30 days')->format('Y-m-d');
|
||||
return Product::where('created_at', '>', $date)->count();
|
||||
}
|
||||
|
||||
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
|
||||
|
||||
Reference in New Issue
Block a user