From ab2a5a4bbf4bf9d8816327acaabefd286d5dd4c2 Mon Sep 17 00:00:00 2001 From: meghamalore Date: Tue, 4 Jun 2024 12:41:20 +0530 Subject: [PATCH] fixed manage seller profile product count issue --- .../Admin/ManageSellerProfileController.php | 9 +++---- app/Models/MarketplaceSellerForm.php | 6 +++-- app/helper.php | 26 ++++++++++++------- .../manage_investors.blade.php | 1 + .../manage_seller_profile.blade.php | 1 + 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Admin/ManageSellerProfileController.php b/app/Http/Controllers/Admin/ManageSellerProfileController.php index 6540125..5702aef 100644 --- a/app/Http/Controllers/Admin/ManageSellerProfileController.php +++ b/app/Http/Controllers/Admin/ManageSellerProfileController.php @@ -24,15 +24,14 @@ class ManageSellerProfileController extends Controller ->withCount(['aif', 'fre', 'op']) ->latest() ->get(); - dd($sellerProfile->toArray()); return view('Admin.Pages.pre_owned_investment.manage_seller_profile', compact('sellerProfile')); } public function sellerDetails($id) { $sellerProfile = MarketplaceSellerForm::findOrFail($id); - $freListing = MarketplaceFractionalRealEstateSeller::where('seller_forms_id', $id)->get(); - $aifListing = MarketplaceAlternativeInvestmentFundSeller::where('seller_forms_id', $id)->get(); + $freListing = MarketplaceFractionalRealEstateSeller::where('seller_forms_id', $id)->where('current_market_value_of_the_property','!=',0)->get(); + $aifListing = MarketplaceAlternativeInvestmentFundSeller::where('seller_forms_id', $id)->where('no_of_units_you_wish_to_sell','!=',0)->get(); $opListing = MarketplaceOtherProductsSeller::where('seller_forms_id', $id)->get(); $id = $id; $productsSold = $this->productsSold($sellerProfile); @@ -50,7 +49,7 @@ class ManageSellerProfileController extends Controller $buyerArr = array(); $buyerArr['product_name'] = $data->name_of_the_aif_fund; $buyerArr['buyer'] = $buyerData->name; - $buyerArr['company'] = $data->type_of_fund; + $buyerArr['company'] = $data->type_of_fund == '' ? 'N/A' : $data->type_of_fund ; $buyerArr['seller_price'] = $buyerData->total_purchase_value; array_push($productsSold, $buyerArr); } @@ -63,7 +62,7 @@ class ManageSellerProfileController extends Controller $buyerArr = array(); $buyerArr['product_name'] = $data->property_name; $buyerArr['buyer'] = $buyerData->name; - $buyerArr['company'] = $data->asset_type; + $buyerArr['company'] = $data->asset_type == '' ? 'N/A' : $data->asset_type ; $buyerArr['seller_price'] = $buyerData->total_purchase_value; array_push($productsSold, $buyerArr); } diff --git a/app/Models/MarketplaceSellerForm.php b/app/Models/MarketplaceSellerForm.php index af353f7..e42b31d 100644 --- a/app/Models/MarketplaceSellerForm.php +++ b/app/Models/MarketplaceSellerForm.php @@ -19,13 +19,15 @@ class MarketplaceSellerForm extends Model public function aif(){ // return $this->hasMany(MarketplaceAlternativeInvestmentFundSeller::class,'seller_forms_id')->where('listing_status', '!=','Hide')->where('status','Approved'); - return $this->hasMany(MarketplaceAlternativeInvestmentFundSeller::class,'seller_forms_id')->where('status','Approved'); + // return + return $this->hasMany(MarketplaceAlternativeInvestmentFundSeller::class,'seller_forms_id')->where('status','Approved')->where('no_of_units_you_wish_to_sell','!=',0); + // dd($data); // return $this->hasMany(MarketplaceAlternativeInvestmentFundSeller::class,'seller_forms_id'); } public function fre(){ // return $this->hasMany(MarketplaceFractionalRealEstateSeller::class,'seller_forms_id')->where('listing_status', '!=','Hide')->where('status','Approved'); - return $this->hasMany(MarketplaceFractionalRealEstateSeller::class,'seller_forms_id')->where('status','Approved'); + return $this->hasMany(MarketplaceFractionalRealEstateSeller::class,'seller_forms_id')->where('status','Approved')->where('current_market_value_of_the_property','!=',0); // $data = $this->hasMany(MarketplaceFractionalRealEstateSeller::class,'seller_forms_id')->where('status','Approved'); // dd($data); diff --git a/app/helper.php b/app/helper.php index 1e9d15a..ad011bc 100644 --- a/app/helper.php +++ b/app/helper.php @@ -325,24 +325,30 @@ function getAllSoldProducts($sellerFormId) $marketplaceAIFPRoducts = MarketplaceAlternativeInvestmentFundSeller::where('seller_forms_id', $sellerFormId)->get(); foreach ($marketplaceAIFPRoducts as $data) { - if (MarketplaceBuyerForm::where(['table' => 'marketplace_aif_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { - $productsSold++; + if($data->no_of_units_you_wish_to_sell == 0) + { + if (MarketplaceBuyerForm::where(['table' => 'marketplace_aif_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { + $productsSold++; + } } } $marketplaceFREPRoducts = MarketplaceFractionalRealEstateSeller::where('seller_forms_id', $sellerFormId)->get(); foreach ($marketplaceFREPRoducts as $data) { - if (MarketplaceBuyerForm::where(['table' => 'marketplace_fre_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { - $productsSold++; + if($data->current_market_value_of_the_property == 0) + { + if (MarketplaceBuyerForm::where(['table' => 'marketplace_fre_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { + $productsSold++; + } } } - $marketplaceOPPRoducts = MarketplaceOtherProductsSeller::where('seller_forms_id', $sellerFormId)->get(); - foreach ($marketplaceOPPRoducts as $data) { - if (MarketplaceBuyerForm::where(['table' => 'marketplace_op_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { - $productsSold++; - } - } + // $marketplaceOPPRoducts = MarketplaceOtherProductsSeller::where('seller_forms_id', $sellerFormId)->get(); + // foreach ($marketplaceOPPRoducts as $data) { + // if (MarketplaceBuyerForm::where(['table' => 'marketplace_op_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) { + // $productsSold++; + // } + // } return $productsSold; } diff --git a/resources/views/Admin/Pages/pre_owned_investment/manage_investors.blade.php b/resources/views/Admin/Pages/pre_owned_investment/manage_investors.blade.php index e2bb886..b2094db 100644 --- a/resources/views/Admin/Pages/pre_owned_investment/manage_investors.blade.php +++ b/resources/views/Admin/Pages/pre_owned_investment/manage_investors.blade.php @@ -162,6 +162,7 @@ @foreach ($productsSold as $data) + {{-- @dd($data) --}}
+ {{-- @dd($profile); --}} {{$profile->aif_count + $profile->fre_count + $profile->op_count}} @php($getAllSoldProducts = getAllSoldProducts($profile->id)) {{$getAllSoldProducts}}