path()); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $category = Category::find(Category::VentureCapitalFundId); $text = $category->category_name; $category_id = $category->id; $excelFileName = 'VentureCapitalFundsTemplate.xlsx'; $route = route('manage.venture-capital-fund.store'); return view('Admin.Pages.manage_freeu_investment.upload-product.alternative-investment-fund', compact('text', 'category_id', 'excelFileName', 'route')); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { request()->validate([ 'productFile' => 'required|mimes:xlx,xls,xlsx|max:2048' ]); $category_type = $request->category_id; $category = Category::find($request->category_id); // dd($category); Excel::import(new AlternativeInvestmentFundImport($category_type), $request->file('productFile')); // return back()->with('success', "$category->category_name Imported Successfully."); return redirect()->route('manage.products')->with('success', "$category->category_name Imported Successfully."); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $alternativeInvestmentFund = Product::with('category', 'alternativeInvestmentFund','product_images')->alternativeInvestmentFund()->find($id); // dd(Product::find($id)); // dd($alternativeInvestmentFund); return view('Admin.Pages.manage_freeu_investment.view-product.alternative-investment-fund', compact('alternativeInvestmentFund')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $companies = Company::active()->pluck('company_name', 'id'); $alternativeInvestmentFund = Product::with('category', 'alternativeInvestmentFund','product_images')->alternativeInvestmentFund()->find($id); // dd($alternativeInvestmentFund); return view('Admin.Pages.manage_freeu_investment.edit-product.alternative-investment-fund', compact('alternativeInvestmentFund', 'companies')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // dd($request->all()); // $request->validate([ // 'fund_name' => 'required' // ]); // dd($request->all()); $validate = Validator::make($request->all(),[ 'fund_name' => 'required', 'presentation'=>"mimes:pdf,zip,jpeg,jpg,png", 'fact_sheet'=>"mimes:pdf,zip,jpeg,jpg,png", 'type' => 'required', 'geographic_focus' => 'required', ],[ 'required' => "This :attribute field is required", 'mimes' => "This :attribute field extension must be pdf,zip,jpeg,jpg,png", ]); $validationMessage = validationErrorMessage($validate); if ($validationMessage) { return response()->json( [ 'status' => 400, 'message' => $validationMessage ] ); } // dd($request->all()); // $count = AlternativeInvestmentFund::where('fund_name',$request->fund_name)->count(); $alternativeInvestmentFund = AlternativeInvestmentFund::where('id', $request->id)->update([ // 'slug' => Str::slug($request->fund_name).'-'.$count+1, 'fund_name' => $request->fund_name, 'geographic_focus' => $request->geographic_focus, 'companies_id' => $request->companies_id, 'registration_number' => $request->registration_number, 'fund_category' => $request->fund_category, 'fund_structure' => $request->fund_structure, 'fund_strategy' => $request->fund_strategy, 'fund_domicile' => $request->fund_domicile, 'fund_manager_name' => $request->fund_manager_name, 'website_of_the_fund' => $request->website_of_the_fund, 'fund_manager_experience' => $request->fund_manager_experience, 'sponsor' => $request->sponsor, 'manager' => $request->manager, 'trustee' => $request->trustee, 'auditor' => $request->auditor, 'valuer_tax_advisor' => $request->valuer_tax_advisor, 'credit_rating' => $request->credit_rating, 'open_date' => $request->open_date, 'first_close_date' => $request->first_close_date, 'final_close_date' => $request->final_close_date, 'tenure_from_final_date' => $request->tenure_from_final_date, 'commitment_period' => $request->commitment_period, 'native_currency' => $request->native_currency, 'target_corpus' => $request->target_corpus, 'investment_manager_contribution' => $request->investment_manager_contribution, 'minimum_capital_commitment' => $request->minimum_capital_commitment, 'intial_drawdown' => $request->intial_drawdown, 'accepting_overseas_investment' => $request->accepting_overseas_investment, 'target_irr' => $request->target_irr, 'management_fees_and_carry' => $request->management_fees_and_carry, 'hurdle_rate' => $request->hurdle_rate, 'other_expenses' => $request->other_expenses, 'focused_sectors_industries' => $request->focused_sectors_industries, 'regions_covered' => $request->regions_covered, 'isin_code' => $request->isin_code, 'focused_real_estate_sectors' => $request->focused_real_estate_sectors, 'rera_complied_property' => $request->rera_complied_property, 'return_on_investment' => $request->return_on_investment, 'return_on_investment_irr_dpi_rvpi_tvpi' => $request->return_on_investment_irr, 'valuation_per_sector' => $request->valuation_per_sector, 'focused_funds' => $request->focused_funds, 'trading_strategy' => $request->trading_strategy, // 'trading_strategy_used'=>$request->trading_strategy_used, 'involved_in_short_selling' => $request->involved_in_short_selling, 'minimum_investment' => $request->min_investment, ]); // dd($id); $product = Product::where('id', $request->alternative_id)->first(); // dd($product); if($request->has('presentation')){ if(\File::exists(public_path('/uploads/product/presentation/'.$product->presentation))){ \File::delete(public_path('/uploads/product/presentation/'.$product->presentation)); } $productpresentation = time().'_presentation'.'.'.$request->presentation->extension(); $request->presentation->move(public_path('/uploads/product/presentation'),$productpresentation); $updatepresentation = Product::where('id', $request->alternative_id)->update([ 'presentation'=> $productpresentation, ]); } if($request->has('fact_sheet')){ if(\File::exists(public_path('/uploads/product/fact_sheet/'.$product->fact_sheet))){ \File::delete(public_path('/uploads/product/fact_sheet'.$product->fact_sheet)); } $productfactsheet = time().'_factsheet'.'.'.$request->fact_sheet->extension(); $request->fact_sheet->move(public_path('uploads/product/fact_sheet'),$productfactsheet); $updatefactsheet = Product::where('id', $request->alternative_id)->update([ 'fact_sheet'=>$productfactsheet,]); } if ($request->hasFile('images')) { // dd($request->hasFile('images')); // $edit_program_images = ProgramImage::where('programs_xid', $program_id)->delete(); foreach ($request->file('images') as $key => $file) { $filename = date('YmdHi') . '_' . $file->getClientOriginalName(); $file->move(public_path('assets/uploads/product_images'), $filename); $images = 'assets/uploads/product_images/' . $filename; $alternativeInvestmentFund = new ProductImage(); $alternativeInvestmentFund->product_xid = $request->alternative_id; $alternativeInvestmentFund->images = $images; $alternativeInvestmentFund->save(); } } // $imagesToRemove = $request->input('images_to_remove')[0]; // // dd($imagesToRemove); // if (!empty($imagesToRemove)) { // $imagesToRemoveJson = $request->input('images_to_remove')[0]; // $imagesToRemove = json_decode($imagesToRemoveJson); // foreach ($imagesToRemove as $imageId) { // $userFile = ProductImage::find($imageId); // if ($userFile) { // $file_path = public_path($userFile->images); // if (file_exists($file_path)) { // unlink($file_path); // } // // Delete the record from the database // $userFile->delete(); // } // } // } $aif = AlternativeInvestmentFund::find($request->id); MonthlyUpdateMaster::where('products_id',$aif->products_id)->update(['investment_platform'=>$request->companies_id]); $type = Product::where('id',$aif->products_id)->update(['type' => $request->type,'description'=> $request->description]); return response()->json(['status' => 200, 'message' => "$request->category Details Updated Successfully"]); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } public function delete_image_capital_fund(Request $request){ // dd("requ",$request->all()); $image = ProductImage::find($request->image_id); if (!$image) { return response()->json(['success' => false, 'status' => 404, 'message' => 'Image not found']); } $imagePath = public_path($image->images); if (file_exists($imagePath)) { // Delete the image file unlink($imagePath); // Delete the image record from the database $image->delete(); return response()->json(['success' => true, 'status' => 200, 'message' => 'Image deleted successfully']); } else { return response()->json(['success' => false, 'status' => 404, 'message' => 'Image file not found']); } } public function delete_image_fund(Request $request){ // dd("requ",$request->all()); $image = ProductImage::find($request->image_id); $previous_image = public_path($image->images); File::delete($previous_image); $image->id = $request->image_id; $image->delete(); return response()->json(['success' => true, 'status' => 200]); } }