Commit 3364ce5a2430f439505198675c71e76f1519a9b0
Merge branch 'discount' of gitlab.artweb.com.ua:Alex/semena
Showing
2 changed files
with
28 additions
and
2 deletions
Show diff stats
src/app/backend/controllers/DiscountController.php
| @@ -224,12 +224,12 @@ class DiscountController extends Controller | @@ -224,12 +224,12 @@ class DiscountController extends Controller | ||
| 224 | 224 | ||
| 225 | if ($status == 1) { | 225 | if ($status == 1) { |
| 226 | 226 | ||
| 227 | - $this->models->getDiscount()->updateData(['status' => 0], $id); | 227 | + $this->models->getDiscount()->updateStatus('0', $id); |
| 228 | 228 | ||
| 229 | } | 229 | } |
| 230 | elseif ($status == 0) { | 230 | elseif ($status == 0) { |
| 231 | 231 | ||
| 232 | - $this->models->getDiscount()->updateData(['status' => 1], $id); | 232 | + $this->models->getDiscount()->updateStatus('1', $id); |
| 233 | 233 | ||
| 234 | } | 234 | } |
| 235 | 235 |
src/lib/models/discount.php
| @@ -198,6 +198,32 @@ class discount extends \db | @@ -198,6 +198,32 @@ class discount extends \db | ||
| 198 | 'id' => $id | 198 | 'id' => $id |
| 199 | ] | 199 | ] |
| 200 | ); | 200 | ); |
| 201 | + | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + * Switch status indicator | ||
| 206 | + * @param bool $status | ||
| 207 | + * @param $id | ||
| 208 | + * @return bool | ||
| 209 | + */ | ||
| 210 | + public function updateStatus($status, $id) { | ||
| 211 | + | ||
| 212 | + return $this->exec( | ||
| 213 | + ' | ||
| 214 | + UPDATE | ||
| 215 | + public.discount | ||
| 216 | + SET | ||
| 217 | + status = :status | ||
| 218 | + WHERE | ||
| 219 | + id = :id | ||
| 220 | + ', | ||
| 221 | + [ | ||
| 222 | + 'status' => $status, | ||
| 223 | + 'id' => $id | ||
| 224 | + ] | ||
| 225 | + ); | ||
| 226 | + | ||
| 201 | } | 227 | } |
| 202 | 228 | ||
| 203 | /** | 229 | /** |