cleanAndGreenAssets()->getData(); $learnMore = (new FractionalRealEstateFrontendController)->cleanAndGreenAssetsQuestionAndAnswer()->getData(); $faqs = (new FractionalRealEstateFrontendController)->cleanAndGreenAssetsQuestionAndAnswerFaqs()->getData(); return view('Frontend.Pages.clean-and-green-assets.index', compact('cleanAndGreenAssets','learnMore','faqs')); } public function product($slug) { // $cleanAndGreenAsset = CleanAndGreenAsset::where('slug',$slug)->first(); $cleanAndGreenAsset = $this->cleanAndGreenAssetsData($slug)->getData()->data; $otherCAGA = CleanAndGreenAsset::query() ->join('products', 'clean_and_green_assets.products_id', 'products.id') ->where(['status' => true, 'categories_id' => 26]) // ->where('status',false) ->where('slug', '!=', $slug) // ->where('categories_id',26) ->get(); $productData = CleanAndGreenAsset::where('slug','=',$slug)->first(); $productData = Product::where('id','=',$productData->products_id)->first(); return view('Frontend.Pages.clean-and-green-assets.product', compact('cleanAndGreenAsset','otherCAGA','productData')); } // public function cleanAndGreenAssets(){ // $cleanAndGreenAssets = Product::with('cleanAndGreenAssets', 'category')->cleanAndGreenAssets()->active()->get(); // return (object)[ // 'status' => 200, // 'data' => $cleanAndGreenAssets // ]; // // return $cleanAndGreenAssets; // } public function cleanAndGreenAssets() { try { return (new test(Product::has('cleanAndGreenAssets')->with('cleanAndGreenAssets.companies')->active()->get())) ->response() ->setStatusCode(200); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()], 400); } } public function cleanAndGreenAssetsData($slug) { try { return (new CleanAndGreenAssetsResource(CleanAndGreenAsset::where('slug', $slug)->first())) ->response() ->setStatusCode(200); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()], 400); } } }