Merge branch 'main' of https://github.com/Ritikeshyadav/my-freeu into HritikFreeu
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\ProductImage;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -352,6 +353,11 @@ class Product extends Model
|
||||
if ($value)
|
||||
return imagePath('public/uploads/real_estate/photos/') . $value;
|
||||
}
|
||||
public function product_images()
|
||||
{
|
||||
return $this->hasMany(ProductImage::class,'product_xid','id');
|
||||
}
|
||||
|
||||
|
||||
// public function scopeGetAllDetails($query)
|
||||
// {
|
||||
|
||||
13
app/Models/ProductImage.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class ProductImage extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
BIN
public/assets/uploads/product_images/202404031636_download.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/assets/uploads/product_images/202404031638_download.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/assets/uploads/product_images/202404031640_download.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/assets/uploads/product_images/202404031645_download.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
@@ -4,6 +4,36 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
|
||||
<style>
|
||||
.img-thumbs {
|
||||
background: #eee;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 0.25rem;
|
||||
margin: 1.5rem 0;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
.img-thumbs-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edit_wrapper-thumb, .wrapper-thumb {
|
||||
position: relative;
|
||||
display:inline-block;
|
||||
/*margin: 1rem 0;*/
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.img-preview-thumb {
|
||||
background: #fff;
|
||||
border: 1px solid none;
|
||||
border-radius: 0.25rem;
|
||||
box-shadow: 0.125rem 0.125rem 0.0625rem rgba(0, 0, 0, 0.12);
|
||||
margin-right: 1rem;
|
||||
max-width: 140px;
|
||||
padding: 0.25rem;
|
||||
}
|
||||
</style>
|
||||
<!--begin::Main-->
|
||||
|
||||
<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
|
||||
@@ -1044,6 +1074,46 @@
|
||||
<input type="file" class="form-control form-control-solid" name="fact_sheet" />
|
||||
</div>
|
||||
|
||||
{{-- <div class="namediv">
|
||||
<label>Gallery :</label>
|
||||
<div class="include_error">
|
||||
<input type="file" class="form-control" name="images[]" value="" multiple id="upload-img" />
|
||||
</div>
|
||||
<input type="hidden" name="images_to_remove[]" id="images-to-remove">
|
||||
@if(isset($alternativeInvestmentFund['product_images']) && count($alternativeInvestmentFund['product_images']) > 0)
|
||||
<div class="img-thumbs" id="img-preview">
|
||||
@foreach($alternativeInvestmentFund['product_images'] as $image)
|
||||
<div class="edit_wrapper-thumb">
|
||||
<img src="{{asset('public/'.$image['images']) }}" alt="Image {{ $image['id'] }}" height="140px"
|
||||
width="140px">
|
||||
<span class="edit_remove-btn"
|
||||
data-image_id = "{{ $image['id'] }}"
|
||||
data-image_path ="{{$image['images']}}">x</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div> --}}
|
||||
|
||||
<div class="active-edit col-md-6">
|
||||
<label>Gallery <span style="color:red;">*</span> :</label>
|
||||
<div class="include_error">
|
||||
<input type="file" class="form-control" name="image[]" value="" multiple id="upload-img" />
|
||||
</div>
|
||||
<input type="hidden" name="images_to_remove[]" id="images-to-remove">
|
||||
@if(isset($alternativeInvestmentFund['product_images']) && count($alternativeInvestmentFund['product_images']) > 0)
|
||||
<div class="img-thumbs" id="img-preview">
|
||||
@foreach($alternativeInvestmentFund['product_images'] as $image)
|
||||
<div class="edit_wrapper-thumb">
|
||||
<img src="{{asset('public/'.$image['images']) }}" alt="Image {{ $image['id'] }}" height="140px"
|
||||
width="140px">
|
||||
<span class="edit_remove-btn" data-image_id = "{{ $image['id'] }}" data-image_path ="{{$image['images']}}">x</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1643,6 +1713,145 @@
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//**************************************************************** Multi image uploding start *******************************************************************
|
||||
var imgUpload = document.getElementById('upload-img')
|
||||
, imgPreview = document.getElementById('img-preview')
|
||||
, imgUploadForm = document.getElementById('form-upload')
|
||||
, totalFiles
|
||||
, previewTitle
|
||||
, previewTitleText
|
||||
, img;
|
||||
|
||||
imgUpload.addEventListener('change', previewImgs, true);
|
||||
|
||||
function previewImgs(event) {
|
||||
totalFiles = imgUpload.files.length;
|
||||
|
||||
if (!!totalFiles) {
|
||||
imgPreview.classList.remove('img-thumbs-hidden');
|
||||
}
|
||||
|
||||
for (var i = 0; i < totalFiles; i++) {
|
||||
wrapper = document.createElement('div');
|
||||
wrapper.classList.add('wrapper-thumb');
|
||||
removeBtn = document.createElement("span");
|
||||
nodeRemove = document.createTextNode('x');
|
||||
removeBtn.classList.add('remove-btn');
|
||||
removeBtn.appendChild(nodeRemove);
|
||||
img = document.createElement('img');
|
||||
img.src = URL.createObjectURL(event.target.files[i]);
|
||||
img.classList.add('img-preview-thumb');
|
||||
wrapper.appendChild(img);
|
||||
wrapper.appendChild(removeBtn);
|
||||
imgPreview.appendChild(wrapper);
|
||||
$('.remove-btn').click(function () {
|
||||
$(this).parent('.wrapper-thumb').remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
//**************************************************************** Multi image uploding end *******************************************************************
|
||||
|
||||
// $('.edit_remove-btn').on("click", function () {
|
||||
// // let url_path = base_url;
|
||||
// var image_id = $(this).data("image_id");
|
||||
// var image_path = $(this).data("image_path");
|
||||
// // alert(image_path);
|
||||
|
||||
// // Remove the image preview from the DOM
|
||||
// $(this).closest('.edit_wrapper-thumb').remove();
|
||||
|
||||
// // Update the hidden input field to include the image path for deletion
|
||||
// var imagesToRemove = $('#images-to-remove').val();
|
||||
// if (imagesToRemove) {
|
||||
// imagesToRemove += ',' + image_path;
|
||||
// } else {
|
||||
// imagesToRemove = image_path;
|
||||
// }
|
||||
// $('#images-to-remove').val(imagesToRemove);
|
||||
|
||||
// // Ask for confirmation
|
||||
// if (confirm("Are you sure you want to delete this image?")) {
|
||||
// $.ajaxSetup({
|
||||
// headers: {
|
||||
// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
// }
|
||||
// });
|
||||
|
||||
// $.ajax({
|
||||
// type: "DELETE",
|
||||
// dataType: "json",
|
||||
// url: "{{route('delete_image')}}",
|
||||
// data: {
|
||||
// image_id: image_id,
|
||||
// image_path: image_path,
|
||||
// },
|
||||
// success: function (response) {
|
||||
// if (response.status == 200) {
|
||||
// toastr.success('Image Deleted Successfully');
|
||||
// setTimeout(function () {
|
||||
// // Redirect or perform any other action after successful deletion.
|
||||
// // window.location.href = url_path + "/programe_edit";
|
||||
// }, 1000);
|
||||
// } else {
|
||||
// toastr.error("Something went wrong");
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
$('.edit_remove-btn').on("click", function () {
|
||||
var image_id = $(this).data("image_id");
|
||||
var image_path = $(this).data("image_path");
|
||||
|
||||
var imagesToRemove = $('#images-to-remove');
|
||||
|
||||
// Get the current value and parse it as an array
|
||||
var removedImages = imagesToRemove.val() ? JSON.parse(imagesToRemove.val()) : [];
|
||||
|
||||
// Only push to the array if the imageId is not null
|
||||
if (image_id) {
|
||||
removedImages.push(image_id);
|
||||
}
|
||||
|
||||
// Update the hidden input with the updated array as JSON string
|
||||
imagesToRemove.val(JSON.stringify(removedImages));
|
||||
|
||||
// Remove the image element from the DOM
|
||||
$(this).parent('.edit_wrapper-thumb').remove();
|
||||
|
||||
// Ask for confirmation
|
||||
if (confirm("Are you sure you want to delete this image?")) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "{{route('delete_image')}}",
|
||||
data: {
|
||||
image_id: image_id,
|
||||
image_path: image_path,
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.status == 200) {
|
||||
toastr.success('Image Deleted Successfully');
|
||||
setTimeout(function () {
|
||||
// Redirect or perform any other action after successful deletion.
|
||||
// window.location.href = url_path + "/programe_edit";
|
||||
}, 1000);
|
||||
} else {
|
||||
toastr.error("Something went wrong");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
@@ -612,8 +612,9 @@ Route::middleware([BackendAccess::class])->group(function () {
|
||||
Route::post("monthly-updates-change-status", 'monthlyUpdateChangeStatus')->name('monthly-updates-change-status');
|
||||
Route::post("redeem-with-sold-amount",'redeemWithSoldAmount')->name('redeem-with-sold-amount');
|
||||
});
|
||||
|
||||
|
||||
//Manage FreeU Investments
|
||||
Route::delete('delete_image', [VentureCapitalFundController::class, 'delete_image'])->name('delete_image');
|
||||
Route::prefix('manage-investments')->group(function () {
|
||||
Route::controller(ManageFreeUInvestmentController::class)->as('manage.')->group(function () {
|
||||
Route::get("/products", 'index')->name('products');
|
||||
@@ -622,6 +623,7 @@ Route::middleware([BackendAccess::class])->group(function () {
|
||||
Route::get("/fractional-real-estate/upload", 'addProduct')->name('addproduct');
|
||||
Route::post("/product/post", 'uploadFile')->name('postproduct');
|
||||
Route::delete("/product/delete", 'productDelete')->name('product-delete');
|
||||
|
||||
|
||||
//Bonds
|
||||
Route::prefix('bonds/upload/')->group(function () {
|
||||
|
||||