I want to make an input in the admin panel with which you can increase / decrease prices in several tables in db by %. At the moment, I did it through a filter
{
return [
new TwigSimpleFilter('price_kiev', [$this, 'formatPriceKiev'])
];
}
public function getPriceEditKiev()
{
$result = DB::table('another_pricelist_edit')->select('price_edit_kiev')->where('id', 1)->first();
return $result->price_edit_kiev;
}
public function formatPriceKiev($number)
{
$a = $this->getPriceEditKiev();
if ($a >= 1) {
$price = $number + $number / 100 * $a;
return round($price, -1);
}else{
return $number;
}
}
markup:
<td class="column-3">
{{ item.price_kiev_1 | price_kiev | number_format(0, '', ' ' ) }}</td>
admin panel with tables:
input where I enter the number for the filter, which I want to remake in order to use it to change the prices in the table by a percentage:
In short, how can I make an input in the admin panel with which I can update the prices in the tables in database? maybe there are similar guides, I will be grateful
sql something like this:
update
table1
set
table1.price = (price + price)/100 * input;
select
*
from
table1;
where -> input: num %