Ejemplo n.º 1
0
 /**
  * @param Model|RetailerProduct $retailerProduct
  * @param array                 $data
  */
 private function setData($retailerProduct, &$data)
 {
     if ($retailerProduct->type === 'MP' && $retailerProduct->facultative) {
         $flag_product = false;
         switch ($this->profile->slug) {
             case 'COP':
                 if ($this->profile->slug === 'COP' && $retailerProduct->companyProduct->ad_company_id === $this->user->retailerUser->company->id) {
                     $flag_product = true;
                 }
                 break;
             case 'SEP':
                 if ($this->user->retailerUser->products()->where('ad_products.id', $retailerProduct->companyProduct->product->id)->count() === 1) {
                     $flag_product = true;
                 }
                 break;
         }
         if ($flag_product) {
             $product = $retailerProduct->companyProduct->product;
             $product->rp = $retailerProduct;
             switch ($product->code) {
                 case 'de':
                     $product->records = $this->facultativeDeRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
                 case 'au':
                     $product->records = $this->facultativeAuRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
                 case 'td':
                     $product->records = $this->facultativeTdRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
             }
             array_push($data['products'], $product);
         }
     }
 }