Merge branch 'main' of https://github.com/Ritikeshyadav/my-freeu into HritikFreeu
This commit is contained in:
@@ -11,6 +11,7 @@ use Illuminate\Support\Str;
|
||||
use App\Models\AlternativeInvestmentFund;
|
||||
use App\Models\Product;
|
||||
use App\Models\Company;
|
||||
use App\Models\ProductImage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class VentureCapitalFundController extends Controller
|
||||
@@ -81,7 +82,7 @@ class VentureCapitalFundController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$companies = Company::active()->pluck('company_name', 'id');
|
||||
$alternativeInvestmentFund = Product::with('category', 'alternativeInvestmentFund')->alternativeInvestmentFund()->find($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'));
|
||||
}
|
||||
@@ -197,6 +198,41 @@ class VentureCapitalFundController extends Controller
|
||||
'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);
|
||||
|
||||
$type = Product::where('id',$aif->products_id)->update(['type' => $request->type]);
|
||||
@@ -213,4 +249,15 @@ class VentureCapitalFundController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function delete_image(Request $request){
|
||||
$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]);
|
||||
// dd("requ",$request->all());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user