Пример #1
0
 /**
  * Prepares the form widget view data
  */
 public function prepareVars()
 {
     $sessionKey = input('sessionKey') ?: $this->sessionKey;
     $product = $this->model->product_id ? Product::findOrNew($this->model->product_id) : new Product();
     $this->vars['selectionIds'] = $this->model->selections()->lists('id');
     $this->vars['options'] = $product->options()->withDeferred($sessionKey)->get();
 }
Пример #2
0
 /**
  * Validate that no inventories exist matching our selection signature
  *
  * @throws \October\Rain\Exception\ValidationException
  * @return void
  */
 public function validateSelections($selections, $sessionKey = null)
 {
     $product = $this->product_id ? Product::findOrNew($this->product_id) : new Product();
     $inventory = $product->inventories()->withDeferred($sessionKey)->whereHasSelections($selections);
     if ($this->id) {
         $inventory->where('id', '!=', $this->id);
     }
     if ($inventory->exists()) {
         $error = Lang::get('bedard.shop::lang.inventory.signature_collision');
         Flash::error($error);
         throw new ValidationException($error);
     }
 }