/** * @param GammaSelection $gamma */ protected function denyDeactivation(GammaSelection $gamma) { //when denying a deactivating of a product, we need to make sure the combination is still selected $exists = $gamma->where('category_id', $this->notification->category->id)->where('brand_id', $this->notification->brand->id)->first(); if (!$exists) { $gamma->create(['account_id' => $this->notification->account_id, 'brand_id' => $this->notification->brand_id, 'category_id' => $this->notification->category_id]); } }
/** * @param GammaSelection $gamma * @param $notification */ protected function deleteExistingGammaSelection(GammaSelection $gamma, $notification) { $selections = $gamma->where(['category_id' => $notification->category->id, 'brand_id' => $notification->brand->id])->get(); foreach ($selections as $selection) { $selection->delete(); } }