Exemplo n.º 1
0
 public function actionDelete($id)
 {
     $id = intval($id);
     if ($id <= 0) {
         throw new HttpException(404, 'Указанный Вами товар не найден');
     }
     $good_current = Good::findOne($id);
     if (!$good_current) {
         throw new HttpException(404, 'Указанный Вами товар не найден');
     }
     $transaction = Good::getDb()->beginTransaction();
     try {
         $good_current->delete();
         $transaction->commit();
         return $this->redirect(Url::To(['category/cat', 'id' => $good_current->category_id]));
     } catch (\Exception $ex) {
         $transaction->rollBack();
         throw $ex;
     }
 }