Add new badge. Update screenshot.
This commit is contained in:
2
bin/bash
2
bin/bash
@@ -1,2 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
docker compose exec php-app bash
|
bin/cli bash
|
||||||
BIN
screenshot1.png
BIN
screenshot1.png
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 199 KiB |
@@ -9,10 +9,11 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
|
|
||||||
final class NewController extends BaseController
|
final class NewController extends BaseController
|
||||||
{
|
{
|
||||||
#[Route('/promos', name: 'app_new')]
|
#[Route('/new', name: 'app_new')]
|
||||||
public function __invoke(): Response
|
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('starred')
|
||||||
->orderByDesc('created_by')
|
->orderByDesc('created_by')
|
||||||
->with(['currentPrice'])
|
->with(['currentPrice'])
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Product extends Model
|
|||||||
|
|
||||||
public function isStarred(): bool
|
public function isStarred(): bool
|
||||||
{
|
{
|
||||||
return (bool) $this->starred;
|
return (bool)$this->starred;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currentPrice(): HasOne
|
public function currentPrice(): HasOne
|
||||||
@@ -65,4 +65,10 @@ class Product extends Model
|
|||||||
set: fn(array $value) => json_encode($value),
|
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
|
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
|
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
|
||||||
|
|||||||
@@ -25,13 +25,16 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge text-bg-warning">out of stock</span>
|
<span class="badge text-bg-warning">out of stock</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if product.isnew() %}
|
||||||
|
<span class="badge text-bg-success">is new</span>
|
||||||
|
{% endif %}
|
||||||
<span class="badge text-bg-light">{{ product.subTitle }}</span>
|
<span class="badge text-bg-light">{{ product.subTitle }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" >
|
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" >
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
{% for category in product.categories %}
|
{% for category in product.categories %}
|
||||||
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none" href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li></li>
|
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none" href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="{{ path('app_promos') }}">Promos <span class="badge text-bg-secondary">{{ promosCount() }}</span></a>
|
<a class="nav-link active" aria-current="page" href="{{ path('app_promos') }}">Promos <span class="badge text-bg-secondary">{{ promosCount() }}</span></a>
|
||||||
<a class="nav-link active" aria-current="page" href="{{ path('app_new') }}">New in last 30 days<span class="badge text-bg-secondary">{{ newCount() }}</span></a>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="{{ path('app_new') }}">New in last 30 days <span class="badge text-bg-secondary">{{ newCount() }}</span></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
<form class="d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user