예제 #1
0
 private function passData($id = null)
 {
     $products = new \App\Models\Products();
     if (!is_null($id)) {
         $products = Products::findOrNew($id);
     }
     if (!is_null($id)) {
         $cProducts = Products::where("id_Product", "!=", $id)->whereNull("Deleted")->orderBy('Product_Title')->get()->toArray();
         $attachments = $products->attachments()->get();
         $productFocusSubTypeList = $products->focusSubType()->get();
         $productCompetitors = $products->competitor()->get();
     } else {
         $cProducts = Products::whereNull("Deleted")->orderBy('Product_Title')->get()->toArray();
         if (!Session::has('ProductAttachments')) {
             Session::set('ProductAttachments', $products->attachments()->get());
         }
         $attachments = Session::get("ProductAttachments");
         if (!Session::has('ProductFocusSubType')) {
             Session::set('ProductFocusSubType', $products->focusSubType()->get());
         }
         $productFocusSubTypeList = Session::get("ProductFocusSubType");
         if (!Session::has('ProductCompetitors')) {
             Session::set('ProductCompetitors', $products->competitor()->get());
         }
         $productCompetitors = Session::get("ProductCompetitors");
     }
     //dd($productFocusSubTypeList);
     $pFocus = ProductFocus::all();
     $pfType = ProductFocusType::where("id_Product_Focus", "=", $products->id_Product_Focus ? $products->id_Product_Focus : 1)->get()->toArray();
     $pfsType = ProductFocusSubType::where("id_Product_Focus_Type", "=", $products->id_Product_Focus_Type ? $products->id_Product_Focus_Type : 1)->get()->toArray();
     $pPos = Positions::all()->toArray();
     $competitorProducts = [];
     foreach ($pFocus as $prFocus) {
         $productFocus[$prFocus["id_Product_Focus"]] = $prFocus["Product_Focus"];
     }
     foreach ($pfType as $prfFocus) {
         $productFocusType[$prfFocus["id_Product_Focus_Type"]] = $prfFocus["Product_Focus_Type"];
     }
     foreach ($pfsType as $prfsFocus) {
         $productFocusSubType[$prfsFocus["id_Product_Focus_Sub_Type"]] = $prfsFocus["Product_Focus_Sub_Type"];
     }
     foreach ($cProducts as $cpProducts) {
         $competitorProducts[$cpProducts["id_Product"]] = $cpProducts["Product_Title"];
     }
     foreach ($pPos as $prPos) {
         $positions[$prPos["id_Position"]] = $prPos["Position_Name"];
     }
     $Companies = Companies::SelectOptionsModel();
     $TargetEndUser = TargetEndUser::CheckboxesModel();
     $TargetMarket = TargetMarket::CheckboxesModel();
     $AssetClass = AssetClass::CheckboxesModel();
     $AvailabilityTerritory = AvailabilityTerritory::CheckboxesModel();
     $TargetEndUserSelection = $products->TargetEndUserSelection();
     $TargetMarketSelection = $products->TargetMarketSelection();
     $ClassAssetsSelection = $products->ClassAssetsSelection();
     $TerritorySelection = $products->TerritorySelection();
     return compact("products", "productFocus", "productFocusType", "productFocusSubType", "Companies", "TargetMarket", "TargetEndUser", "AssetClass", "competitorProducts", "AvailabilityTerritory", "positions", "attachments", "TerritorySelection", "TargetEndUserSelection", "TargetMarketSelection", "ClassAssetsSelection", "productFocusSubTypeList", "productCompetitors");
 }
예제 #2
0
 public function getPositionByID(Request $request, $id)
 {
     $data = Positions::getPosDetails($id);
     return response()->json($data);
 }