Update star route.
This commit is contained in:
14
src/Controller/StarController.php
Normal file
14
src/Controller/StarController.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
|
||||
final class StarController extends BaseController
|
||||
{
|
||||
public function __invoke(int $productId): void
|
||||
{
|
||||
Product::find($productId)->toggleStarred()->save();
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
{% block content %}
|
||||
<table class='table table-hover'>
|
||||
<tr>
|
||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none" href="/browser.php/star/{{ product.id }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a></td>
|
||||
<td><img src='{{ product.image }}&width=150' class='img-fluid' alt='{{ product.name }}'/></td>
|
||||
<td><a href='/browser.php/product/{{ product.id }}'>{{ product.name }}</a></td>
|
||||
<td>{{ product.subTitle }}</td>
|
||||
@@ -17,7 +18,6 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
|
||||
<table class='table table-hover table-sm mb-0'>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<table class='table table-hover'>
|
||||
{% for product in products %}
|
||||
<tr>
|
||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none" href="?star={{ product.id }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a></td>
|
||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none" href="/browser.php/star/{{ product.id }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a></td>
|
||||
<td><img src='{{ product.image }}&width=70' class='img-fluid' alt='{{ product.name }}'/></td>
|
||||
<td class="align-middle"><a href='/browser.php/product/{{ product.id }}'>{{ product.name }}</a></td>
|
||||
<td class="align-middle">{{ product.subTitle }}</td>
|
||||
|
||||
Reference in New Issue
Block a user