with('users') ->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(); $opListing = MarketplaceOtherProductsSeller::where('seller_forms_id', $id)->get(); $id = $id; $productsSold = $this->productsSold($sellerProfile); return view('Admin.Pages.pre_owned_investment.manage_investors', compact('sellerProfile', 'aifListing', 'freListing', 'opListing', 'id', 'productsSold')); } public function productsSold($sellerProfile) { $sellerId = $sellerProfile->id; $productsSold = array(); $marketplaceAIFPRoducts = MarketplaceAlternativeInvestmentFundSeller::where('seller_forms_id', $sellerId)->get(); foreach ($marketplaceAIFPRoducts as $data) { $buyers = MarketplaceBuyerForm::where(['table' => 'marketplace_aif_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->get(); foreach ($buyers as $buyerData) { $buyerArr = array(); $buyerArr['product_name'] = $data->name_of_the_aif_fund; $buyerArr['buyer'] = $buyerData->name; $buyerArr['company'] = $data->type_of_fund; $buyerArr['seller_price'] = $buyerData->total_purchase_value; array_push($productsSold, $buyerArr); } } $marketplaceFREPRoducts = MarketplaceFractionalRealEstateSeller::where('seller_forms_id', $sellerId)->get(); foreach ($marketplaceFREPRoducts as $data) { $buyers = MarketplaceBuyerForm::where(['table' => 'marketplace_fre_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->get(); foreach ($buyers as $buyerData) { $buyerArr = array(); $buyerArr['product_name'] = $data->property_name; $buyerArr['buyer'] = $buyerData->name; $buyerArr['company'] = $data->asset_type; $buyerArr['seller_price'] = $buyerData->total_purchase_value; array_push($productsSold, $buyerArr); } } $marketplaceOPPRoducts = MarketplaceOtherProductsSeller::where('seller_forms_id', $sellerId)->get(); foreach ($marketplaceOPPRoducts as $data) { $buyers = MarketplaceBuyerForm::where(['table' => 'marketplace_op_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->get(); foreach ($buyers as $buyerData) { $buyerArr = array(); $buyerArr['product_name'] = $data->property_name; $buyerArr['buyer'] = $buyerData->name; $buyerArr['company'] = $buyerData->instrument_type; $buyerArr['seller_price'] = $buyerData->total_purchase_value; array_push($productsSold, $buyerArr); } } return $productsSold; } public function changeStatus(Request $request) { $changeStatus = MarketplaceSellerForm::where('id', $request->id)->update([ 'status' => $request->status == 0 ? 1 : 0, ]); if ($changeStatus) { return response()->json(['status' => 200, 'message' => 'Status Changed']); } return response()->json(['status' => 400, 'message' => 'Error Changing Status']); } }