/**
  * @param GammaNotification $notifications
  */
 public function handle(GammaNotification $notifications)
 {
     $processingOrExisting = $notifications->where('category_id', $this->category->id)->count();
     if ($processingOrExisting) {
         $message = "can't deactivate, something is still being processed";
         abort(400, $message, ['statustext' => $message]);
     }
     if ($this->category->selection) {
         $this->category->selection->delete();
     }
 }
Beispiel #2
0
 /**
  * @param ProductSelection $products
  * @param GammaNotification $notifications
  * @return bool
  */
 protected function shouldNotRun(ProductSelection $products, GammaNotification $notifications)
 {
     if ($products->countActiveProducts($this->brand->id, $this->category->id, $this->account->id) > 0) {
         return true;
     }
     $payload = ['brand_id' => $this->brand->id, 'category_id' => $this->category->id];
     if ($notifications->where($payload)->count()) {
         return true;
     }
     return false;
 }
 /**
  * @param GammaNotification $notification
  * @param $brand
  * @param $category
  * @return
  */
 protected function findExistingCombination(GammaNotification $notification, $brand, $category)
 {
     $existing = $notification->where('brand_id', $brand->id)->where('category_id', $category->id)->first();
     return $existing;
 }