From edbbc6972ecfee91e023c41d8c1d5279db6f2af4 Mon Sep 17 00:00:00 2001 From: Ritikesh yadav Date: Fri, 17 May 2024 16:47:12 +0530 Subject: [PATCH] fixing changes and product delete issue --- .../Admin/ManageFreeUInvestmentController.php | 9 ++++ .../Frontend/DashboardController.php | 3 +- .../Frontend/MarketPlaceController.php | 2 + app/Models/MarketplaceBuyerForm.php | 4 +- .../manage_freeu_investment.blade.php | 43 ++++++++++++++++++- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/ManageFreeUInvestmentController.php b/app/Http/Controllers/Admin/ManageFreeUInvestmentController.php index 493c2a0..6c0e1e9 100644 --- a/app/Http/Controllers/Admin/ManageFreeUInvestmentController.php +++ b/app/Http/Controllers/Admin/ManageFreeUInvestmentController.php @@ -36,6 +36,7 @@ use App\Models\LeaseBasedFinancing; use App\Models\SecuritizedDebtInstrument; use App\Models\StockFundsRealEstateExchange; use App\Models\AlternativeInvestmentFund; +use App\Models\MonthlyUpdateMaster; use Illuminate\Support\Str; use App\Models\ProductPhotoDocuments; use Illuminate\Support\Facades\Validator; @@ -76,6 +77,14 @@ class ManageFreeUInvestmentController extends Controller public function productDelete(Request $request) { // dd($request->all()); + + $exists = MonthlyUpdateMaster::where('products_id',$request->id)->where('holding_status','Holding')->exists(); + if($exists) + { + return response(['status' => 400, 'message' => 'You can not delete this product because some investor has holding this product']); + } + // dd('hello'); + $product = Product::where('id', $request->id)->delete(); // $FREProduct = FractionalRealEstate::where('products_id',$request->id)->first(); if (FractionalRealEstate::where('products_id', $request->id)->exists()) { diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php index 6c1fa77..a40fb14 100644 --- a/app/Http/Controllers/Frontend/DashboardController.php +++ b/app/Http/Controllers/Frontend/DashboardController.php @@ -385,10 +385,11 @@ class DashboardController extends Controller public function getProductDetail(Request $request) { $id = $request->id; + // dd($id); if($id) { $product_id = MonthlyUpdateMaster::where('id',$id)->value('products_id'); - // dd($product_id); + // dd(FractionalRealEstate::where('products_id',$product_id)->exists()); if(AlternativeInvestmentFund::where('products_id',$product_id)->exists()) { $data = Product::with('alternativeInvestmentFund','categorys')->where('id',$product_id)->first(); diff --git a/app/Http/Controllers/Frontend/MarketPlaceController.php b/app/Http/Controllers/Frontend/MarketPlaceController.php index 736d757..cfb07a8 100644 --- a/app/Http/Controllers/Frontend/MarketPlaceController.php +++ b/app/Http/Controllers/Frontend/MarketPlaceController.php @@ -615,6 +615,8 @@ class MarketPlaceController extends Controller $marketFRE = MarketplaceFractionalRealEstateSeller::where('slug', $slug)->first(); $offering['own-product'] = MarketplaceSellerForm::where(['id' => $marketFRE->seller_forms_id, 'users_id' => auth('sanctum')->id()])->exists(); $offering['data'] = $marketFRE; + // dd($marketFRE); + $offering['invested'] = $this->checkInvestmentInterestedAPI($offering['data'], 'marketplace_fre_sellers')['interested-status']; $offering['invested-data'] = $this->checkInvestmentInterestedDataAPI($offering['data'], 'marketplace_fre_sellers')['interested-status-data']; //new added diff --git a/app/Models/MarketplaceBuyerForm.php b/app/Models/MarketplaceBuyerForm.php index 8c33aa4..8408c06 100644 --- a/app/Models/MarketplaceBuyerForm.php +++ b/app/Models/MarketplaceBuyerForm.php @@ -44,8 +44,8 @@ class MarketplaceBuyerForm extends Model } public function getFundCategoryAttribute($value){ - // return 123; - return $this->attributes['name_of_the_aif_fund']; + return $value; + // return $this->attributes['name_of_the_aif_fund']; // return $this->get_money_format($value); } diff --git a/resources/views/Admin/Pages/manage_freeu_investment/manage_freeu_investment.blade.php b/resources/views/Admin/Pages/manage_freeu_investment/manage_freeu_investment.blade.php index 14e9189..8b279e9 100644 --- a/resources/views/Admin/Pages/manage_freeu_investment/manage_freeu_investment.blade.php +++ b/resources/views/Admin/Pages/manage_freeu_investment/manage_freeu_investment.blade.php @@ -479,6 +479,42 @@ +{{-- blocked_modal start --}} + +{{-- blocked_modal end --}} @endsection @section('scripts') @@ -502,13 +538,18 @@ $('#productDeleteBtn').click(function() { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), }, success: function(result) { + $('#productDeleteModal').modal('hide'); if (result.status == 200) { $('#productDeleteModal').modal('hide'); toastr.success(result.message); setTimeout(function() { window.location.reload(); }, 1500); - } else { + } else if(result.status == 400){ + $('#modal_message').html(result.message); + $('#messagePopup').modal('show'); + } + else { toastr.warning(result.message); } }