Add a tooltip with last update to discontinued items.

This commit is contained in:
Krzysztof Płaczek
2025-02-16 10:22:09 +01:00
parent 81f9c863c7
commit 5c2777999a
5 changed files with 13 additions and 4 deletions

View File

@@ -13,7 +13,6 @@ final class SearchController extends BaseController
public function __invoke(Request $request): Response public function __invoke(Request $request): Response
{ {
$search = $request->query->get('search'); $search = $request->query->get('search');
//dd();
$products = Product::with('price') $products = Product::with('price')
->orWhere([['name', 'like', "%$search%"]]) ->orWhere([['name', 'like', "%$search%"]])
->orWhere([['subTitle', 'like', "%$search%"]])->get(); ->orWhere([['subTitle', 'like', "%$search%"]])->get();

6
templates/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

4
templates/js/script.js Normal file
View File

@@ -0,0 +1,4 @@
(function() {
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
})();

View File

@@ -26,7 +26,7 @@
<span class="badge text-bg-warning">out of stock</span> <span class="badge text-bg-warning">out of stock</span>
{% endif %} {% endif %}
{% if product.isDiscontinued() %} {% if product.isDiscontinued() %}
<span class="badge text-bg-secondary">is discontinued</span> <span class="badge text-bg-secondary" data-bs-toggle="tooltip" data-bs-title="Last update: {{ product.updated_at }}">is discontinued</span>
{% endif %} {% endif %}
{% if product.isNew() %} {% if product.isNew() %}
<span class="badge text-bg-success">is new</span> <span class="badge text-bg-success">is new</span>

View File

@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ryobi crawler</title> <title>Ryobi crawler</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" <link href="templates/css/bootstrap.min.css" rel="stylesheet" />
crossorigin="anonymous"/> <script src="templates/js/script.js" defer></script>
</head> </head>
<body> <body>
<nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1"> <nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1">