fractData()->getData(); $openFRE = Product::has('fractional_real_estate')->with('fractional_real_estate.companies', 'categorys')->open()->active()->latest()->get(); $resaleFRE = Product::has('fractional_real_estate')->with('fractional_real_estate.companies', 'categorys')->resale()->active()->latest()->get(); $fullyFundedFRE = Product::has('fractional_real_estate')->with('fractional_real_estate.companies', 'categorys')->fullyFunded()->active()->latest()->get(); $learnMore = (new FractionalRealEstateFontendController)->fractionalRealEstateQuestionAndAnswer()->getData(); // $faqs = (new FractionalRealEstateFontendController)->fractionalRealEstateQuestionAndAnswerFaqs()->getData(); // dd($openFRE); return view('Frontend.Pages.fractional-real-estate.index', compact('fractionalRealEstate', 'learnMore', 'openFRE', 'resaleFRE', 'fullyFundedFRE')); } public function product($slug) { $fractionalRealEstate = $this->fractionalRealEstateData($slug)->getData()->data; // dd($fractionalRealEstate->products_id); // $otherFRE = FractionalRealEstate::query() // ->join('products', 'fractional_real_estates.products_id', 'products.id') // ->where(['status' => true, 'categories_id' => 2]) // ->where('slug', '!=', $slug) // ->get(); // $productData = FractionalRealEstate::where('slug', '=', $slug)->first(); // dd($productData->toArray(),$fractionalRealEstate); $productData = Product::with('product_images')->where('id', $fractionalRealEstate->products_id)->first(); return view('Frontend.Pages.fractional-real-estate.product', compact('fractionalRealEstate', 'productData')); } public function downloadFilePersantation($filename) { // dd($filename); if (\File::exists('public/uploads/product/presentation/' . $filename)) { // dd('hello'); return response()->download(public_path('/uploads/product/presentation/' . $filename)); } else if (\File::exists('public/uploads/product/fact_sheet/' . $filename)) { return response()->download(public_path('/uploads/product/fact_sheet/' . $filename)); } else { return "file not found"; } // dd('hello'); } public function fractData($type = 'Open') { try { $product = Product::has('fractional_real_estate')->with('fractional_real_estate.companies','product_images')->where('type',$type)->active()->get(); foreach ($product as $fre) { $fre->fractional_real_estate->property_img = $fre->fractional_real_estate->getRawOriginal('property_image'); } return (new test($product)) ->response() ->setStatusCode(200); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()], 400); } } public function fractionalRealEstateData($slug) { try { return (new FractionalRealEstateResource(FractionalRealEstate::where('slug', $slug)->first())) ->response() ->setStatusCode(200); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()], 400); } } public function delete_fractional_image(Request $request){ $image = ProductImage::find($request->image_id); $previous_image = public_path($image->images); // \File::delete($previous_image); if (!empty($previous_image)) { $previousImagePath = $previous_image; if (file_exists($previousImagePath)) { unlink($previousImagePath); } } $image->id = $request->image_id; $image->delete(); return response()->json(['success' => true, 'status' => 200]); // dd("requ",$request->all()); } }