From fd907b7d9256dd0db4d05fc6a23e2cfa8ee0a2b7 Mon Sep 17 00:00:00 2001 From: saparatayev Date: Thu, 15 Jul 2021 15:47:39 +0500 Subject: [PATCH] delete offers from basket and db --- plugins/tps/birzha/components/OfferForm.php | 22 +++++++++++++++++++ .../birzha/components/offerForm/basket.htm | 7 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/plugins/tps/birzha/components/OfferForm.php b/plugins/tps/birzha/components/OfferForm.php index e21b1dd27..2208bf6a5 100644 --- a/plugins/tps/birzha/components/OfferForm.php +++ b/plugins/tps/birzha/components/OfferForm.php @@ -252,6 +252,28 @@ class OfferForm extends ComponentBase ]; } + public function onDeleteOfferFromBasket() { + // delete offer from basket, from db + $offer = Offer::find(Input::get('offer_id')); + $offer->images()->delete(); + $offer->translations()->delete(); + $offer->delete(); + + // then display the rest of offers + $draft_offers = \Auth::user()->offers() + ->where('status','draft') + ->orderBy('created_at', 'desc')->get(); + + $this->page['draft_offers'] = $draft_offers; + $this->page['draft_offers_count'] = count($draft_offers); + $this->page['fee'] = Settings::getValue('fee'); + + + return [ + '#form-steps' => $this->renderPartial('@basket') + ]; + } + protected function validateFileType($data, $rules) { $validator = Validator::make($data, $rules); diff --git a/plugins/tps/birzha/components/offerForm/basket.htm b/plugins/tps/birzha/components/offerForm/basket.htm index 1a12d923e..63375885c 100644 --- a/plugins/tps/birzha/components/offerForm/basket.htm +++ b/plugins/tps/birzha/components/offerForm/basket.htm @@ -35,9 +35,12 @@ -
+ delete-icon -
+ {% endfor %}