diff --git a/app/Http/Controllers/Admin/OverviewController.php b/app/Http/Controllers/Admin/OverviewController.php index ab68900..e0aaf28 100644 --- a/app/Http/Controllers/Admin/OverviewController.php +++ b/app/Http/Controllers/Admin/OverviewController.php @@ -180,9 +180,9 @@ class OverviewController extends Controller // return response()->json(['status' => 400, 'message' => 'This product has already been Sold']); // } // } - // $checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->first(); - // if($checkAlreadySold) - // { + $checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->exists(); + if(!$checkAlreadySold) + { // $marketPlaceId = $checkAlreadySold->associated_id; // if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists()) // { @@ -206,28 +206,58 @@ class OverviewController extends Controller // // } // }else - - if($status == 'Sold'){ + // dd($request->all()); + // if($status == 'Sold'){ $getMarketplaceBuyerUnit = MarketplaceBuyerForm::where('id', $buyerId)->first(); $marketPlaceId = $getMarketplaceBuyerUnit->associated_id; - $getUnits = (int)$getMarketplaceBuyerUnit->no_of_units_you_wish_to_buy; + $getUnits = (int)$getMarketplaceBuyerUnit->no_of_units_you_wish_to_buy ?? 0; + $getBuyingPurchaseValue = (int)$getMarketplaceBuyerUnit->getAttributes()['total_purchase_value']; if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists()) + { + $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first(); + $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell; + $newUnits = $oldUnit - (int)$getUnits; + if($newUnits >= 0) { - $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first(); - $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell; - $newUnits = $oldUnit - (int)$getUnits; - if($newUnits >= 0) - { - $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([ - 'no_of_units_you_wish_to_sell' => $newUnits, - ]); - } - else{ - return response()->json(['status' => 400, 'message' => 'Bid units is more than seller units with '.abs($newUnits).' units']); - } - + $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([ + 'no_of_units_you_wish_to_sell' => $newUnits, + ]); } + else{ + return response()->json(['status' => 400, 'message' => 'Bid units is more than seller units with '.abs($newUnits).' units']); + } + + }else if(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists()) + { + // dd('inside'); + $getFREData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first(); + $freValue = (int)$getFREData->current_market_value_of_the_property; + $nowValue = $freValue - $getBuyingPurchaseValue; + + $percentage = ($freValue - $getBuyingPurchaseValue) / $freValue * 100; + + $expectedSellingPrice = (int)$getFREData->expected_selling_price; + $updateExpectedSellingPrice = $expectedSellingPrice * ($percentage / 100); + // dd($percentage,$updateExpectedSellingPrice); + if($nowValue <= 0) + { + $updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([ + 'current_market_value_of_the_property' => 0, + 'expected_selling_price' => 0, + ]); + }else if($nowValue > 0){ + $updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([ + 'current_market_value_of_the_property' => $nowValue, + 'expected_selling_price' => $updateExpectedSellingPrice, + ]); + } + // else{ + // return response()->json(['status' => 400, 'message' => 'Bid price is more than seller price with ₹'.abs($nowValue)]); + // } + } + // dd('outside'); } + // dd('hello'); $alreadySold = MarketplaceBuyerForm::where('id', $buyerId)->update([ 'status' => $status ]); @@ -337,22 +367,38 @@ class OverviewController extends Controller if (!$check) { abort(404); } - $aifBuyerForm = MarketplaceAlternativeInvestmentFundSeller::with('seller', 'company')->join('marketplace_buyer_forms', 'marketplace_aif_sellers.id', 'marketplace_buyer_forms.associated_id') - ->latest('marketplace_aif_sellers.created_at')->get(); - $freBuyerForm = MarketplaceFractionalRealEstateSeller::with('seller', 'company')->join('marketplace_buyer_forms', 'marketplace_fre_sellers.id', 'marketplace_buyer_forms.associated_id')->latest('marketplace_fre_sellers.created_at')->get(); - $opBuyerForm = MarketplaceOtherProductsSeller::with('seller', 'company')->join('marketplace_buyer_forms', 'marketplace_op_sellers.id', 'marketplace_buyer_forms.associated_id')->latest('marketplace_op_sellers.created_at')->get(); - $completedData = collect(); - $aifBuyerForm->each(function($value) use($completedData){ - $completedData[] = $value; - }); - $freBuyerForm->each(function($value) use($completedData){ - $completedData[] = $value; - }); - // $latestArray = array_merge($aifBuyerForm->toArray(),$freBuyerForm->toArray()); - $newData = $completedData->sortBy('created_at'); + // $aifBuyerForm = MarketplaceAlternativeInvestmentFundSeller::with('seller', 'company', 'buyer')->join('marketplace_buyer_forms', 'marketplace_aif_sellers.id', 'marketplace_buyer_forms.associated_id') + // ->latest('marketplace_aif_sellers.created_at')->get(); + // $freBuyerForm = MarketplaceFractionalRealEstateSeller::with('seller', 'company', 'buyer')->join('marketplace_buyer_forms', 'marketplace_fre_sellers.id', 'marketplace_buyer_forms.associated_id')->latest('marketplace_fre_sellers.created_at')->get(); + // $opBuyerForm = MarketplaceOtherProductsSeller::with('seller', 'company')->join('marketplace_buyer_forms', 'marketplace_op_sellers.id', 'marketplace_buyer_forms.associated_id')->latest('marketplace_op_sellers.created_at')->get(); + + + $marketPlaceBuyerFrom = MarketplaceBuyerForm::where('status','Sold')->get(); + $newData = collect(); + foreach($marketPlaceBuyerFrom as $item){ + if($item->table == 'marketplace_fre_sellers'){ + $item['data'] = MarketplaceFractionalRealEstateSeller::with('seller', 'company',)->where('id',$item->associated_id)->first(); + $newData->push($item); + } + else if($item->table == 'marketplace_aif_sellers') + { + $item['data'] = MarketplaceAlternativeInvestmentFundSeller::with('seller', 'company',)->where('id',$item->associated_id)->first(); + $newData->push($item); + } + } + // dd($newData); + // $completedData = collect(); + // $aifBuyerForm->each(function($value) use($completedData){ + // $completedData[] = $value; + // }); + // $freBuyerForm->each(function($value) use($completedData){ + // $completedData[] = $value; + // }); + // $newData = $completedData->sortBy('buyer.updated_at'); $companies = Company::active()->pluck('company_name', 'id'); - return view('Admin.Pages.pre_owned_investment.transactions', compact('aifBuyerForm', 'freBuyerForm', 'opBuyerForm', 'companies','newData')); + // return view('Admin.Pages.pre_owned_investment.transactions', compact('aifBuyerForm', 'freBuyerForm', 'opBuyerForm', 'companies','newData')); + return view('Admin.Pages.pre_owned_investment.transactions', compact('companies','newData')); } // public function manage_seller_profile() @@ -407,7 +453,7 @@ class OverviewController extends Controller public function updateCompleteTransaction(Request $request) { - + // dd($request->all()); $completedTransactionUpdated = MarketplaceBuyerForm::where('id', $request->buyer_id)->update([ 'complete_units_sold' => $request->final_units_sold, 'complete_sale_value' => $request->final_sale_value, diff --git a/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php b/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php index 7a7166a..59af686 100644 --- a/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php +++ b/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php @@ -156,7 +156,8 @@ class AlternativeInvestmentFundController extends Controller public function ventureCapitalFundProduct($slug) { - $ventureCapitalFund = $this->ventureCapitalData($slug)->getData(); + $ventureCapitalFund = $this->ventureCapitalData($slug)->getData()->data; + // dd($ventureCapitalFund); $otherVCP = AlternativeInvestmentFund::query() ->join('products', 'alternative_investment_funds.products_id', 'products.id') ->where(['status' => true, 'categories_id' => 28]) diff --git a/app/Http/Controllers/Frontend/MarketPlaceController.php b/app/Http/Controllers/Frontend/MarketPlaceController.php index a57604a..fd4348c 100644 --- a/app/Http/Controllers/Frontend/MarketPlaceController.php +++ b/app/Http/Controllers/Frontend/MarketPlaceController.php @@ -19,6 +19,7 @@ class MarketPlaceController extends Controller { $spotlightMarketPlaceListed = $this->spotlightInvestment()['data']; $featuredMarketplaceListed = $this->featuredInvestments(); + // dd($featuredMarketplaceListed); $nonFeaturedMarketplaceListed = $this->nonFeaturedInvestments(); return view('Frontend.Pages.marketplace.index', compact('spotlightMarketPlaceListed', 'featuredMarketplaceListed', 'nonFeaturedMarketplaceListed')); } @@ -70,10 +71,11 @@ class MarketPlaceController extends Controller array_push($marketplaceListed, $freMarketplace); array_push($marketplaceListed, $aifMarketplace); array_push($marketplaceListed, $opMarketplace); + // dd($freMarketplace['fractional-real-estate']); // $marketplaceListed = []; - + return [ @@ -119,45 +121,54 @@ class MarketPlaceController extends Controller // $status = MarketplaceBuyerForm::where(['associated_id'=>$offering['data']->id,'status'=>'Sold'])->exists() ? 'SOLD':'OPEN'; $status = ''; $checkBIDExist = MarketplaceBuyerForm::where('associated_id', $offering['data']->id)->where('status', 'Sold')->exists(); - if($checkBIDExist) - { + if ($checkBIDExist) { $buyerData = MarketplaceBuyerForm::where('associated_id', $offering['data']->id)->where('status', 'Sold')->get(); // dd($buyerData->toArray()); - if(MarketplaceAlternativeInvestmentFundSeller::where('id',$buyerData[0]->associated_id)->exists()) - { + if (MarketplaceAlternativeInvestmentFundSeller::where('id', $buyerData[0]->associated_id)->exists()) { $totalSellUnits = 0; - $buyerData->each(function($data) use($totalSellUnits){ + $buyerData->each(function ($data) use ($totalSellUnits) { return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy; }); - $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$buyerData[0]->associated_id)->first(); + $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id', $buyerData[0]->associated_id)->first(); $aifData = (int)$getAIFData->no_of_units_you_wish_to_sell; $remainUnits = $aifData - $totalSellUnits; - if($remainUnits <= 0) + if ($remainUnits <= 0) { + $status .= 'SOLD'; + } + $status .= 'OPEN'; + } elseif (MarketplaceFractionalRealEstateSeller::where('id', $buyerData[0]->associated_id)->exists()) { + $freData = MarketplaceFractionalRealEstateSeller::where('id', $buyerData[0]->associated_id)->first(); + if($freData->current_market_value_of_the_property < 0) { $status .= 'SOLD'; } $status .= 'OPEN'; } - elseif(MarketplaceFractionalRealEstateSeller::where('id',$buyerData[0]->associated_id)->exists()){ - $status .= 'SOLD'; - } - }else{ + } else { $status .= 'OPEN'; } // dd($status); $invested = $offering['invested']; - + $totalInterestedBuyers = $offering['total-interested-buyers']; $type = $offering['type']; $ownProduct = $offering['own-product']; $logged_in = auth()->guard('users')->check() == true ? true : false; // dd('offering',$offering['invested_data']); $investedData = $offering['invested_data']; - - return view('Frontend.Pages.marketplace.view-offering', compact('offering', 'type', 'invested', - 'totalInterestedBuyers', 'logged_in', 'ownProduct','investedData', 'status')); + + return view('Frontend.Pages.marketplace.view-offering', compact( + 'offering', + 'type', + 'invested', + 'totalInterestedBuyers', + 'logged_in', + 'ownProduct', + 'investedData', + 'status' + )); } public function viewOfferingData($slug) @@ -170,7 +181,9 @@ class MarketPlaceController extends Controller if (!auth()->guard('users')->check()) { $offering['invested'] = false; }; + // $bidFor = ''; if (MarketplaceFractionalRealEstateSeller::where('slug', $slug)->exists()) { + // $bidFor .= 'fractional-real-estate'; $offering['type'] = 'fractional-real-estate'; $marketFRE = MarketplaceFractionalRealEstateSeller::where('slug', $slug)->first(); // if($user_id){ @@ -182,13 +195,14 @@ class MarketPlaceController extends Controller $offering['total-interested-buyers'] = $this->checkInvestmentInterested($offering['data'], 'marketplace_fre_sellers')['total-interested-buyers']; } elseif (MarketplaceAlternativeInvestmentFundSeller::where('slug', $slug)->exists()) { + // $bidFor .= 'alternative-investment-funds'; $offering['type'] = 'alternative-investment-funds'; $marketAIF = MarketplaceAlternativeInvestmentFundSeller::where('slug', $slug)->first(); $offering['own-product'] = $user_id != null ? MarketplaceSellerForm::where(['id' => $marketAIF->seller_forms_id, 'users_id' => $user_id])->exists() : ''; $offering['data'] = $marketAIF; $offering['invested'] = $this->checkInvestmentInterested($offering['data'], 'marketplace_aif_sellers')['interested-status']; $offering['invested_data'] = $this->checkInvestmentInterestedData($offering['data'], 'marketplace_aif_sellers')['interested-status-data']; - + $offering['total-interested-buyers'] = $this->checkInvestmentInterested($offering['data'], 'marketplace_aif_sellers')['total-interested-buyers']; } elseif (MarketplaceOtherProductsSeller::where('slug', $slug)->exists()) { $offering['type'] = 'other-products'; @@ -210,7 +224,7 @@ class MarketPlaceController extends Controller if (auth()->guard('users')->check()) { $interestedStatus = MarketplaceBuyerForm::where(['users_id' => auth()->guard('users')->user()->id, 'table' => $table, 'associated_id' => $offering->id])->first(); } - return ['interested-status-data' => $interestedStatus ]; + return ['interested-status-data' => $interestedStatus]; } public function checkInvestmentInterested($offering, $table) @@ -229,7 +243,7 @@ class MarketPlaceController extends Controller public function buyerForm($slug) { $offering = $this->viewOfferingData($slug); - + $table = $offering['type']; $id = $offering['data']->id; $userData = array(); @@ -257,26 +271,50 @@ class MarketPlaceController extends Controller 'contact_number' => $user->contact_number ?? null, 'email' => $user->email ?? $user->email, ]; - return view('Frontend.Pages.profile.market-list.edit-buyer-form', compact('table', 'id', 'userData','investedData')); + return view('Frontend.Pages.profile.market-list.edit-buyer-form', compact('table', 'id', 'userData', 'investedData')); } public function buyerFormSubmit(Request $request) { - $validator = Validator::make($request->all(), [ - 'id' => 'required', - 'table' => 'required', - 'name' => 'required', - 'city' => 'required', - 'country' => 'required', - 'contact_number' => 'required|numeric|digits:10', - 'email_id' => 'required', - 'no_of_units_you_wish_to_buy' => 'required|numeric', - 'offer_price_per_unit' => 'required|numeric', - ], [ - 'required' => 'The :attribute field must be required', - 'numeric' => 'The :attribute field must be in digits', - 'digits' => 'The :attribute field must have 10 digits', - ]); + // dd($request->all()); + if($request->table == 'alternative-investment-funds') + { + $validator = Validator::make($request->all(), [ + 'id' => 'required', + 'table' => 'required', + 'name' => 'required', + 'city' => 'required', + 'country' => 'required', + 'contact_number' => 'required|numeric|digits:10', + 'email_id' => 'required', + 'no_of_units_you_wish_to_buy' => 'required|numeric', + 'offer_price_per_unit' => 'required|numeric', + ], [ + 'required' => 'The :attribute field must be required', + 'numeric' => 'The :attribute field must be in digits', + 'digits' => 'The :attribute field must have 10 digits', + ]); + }else + { + $validator = Validator::make($request->all(), [ + 'id' => 'required', + 'table' => 'required', + 'name' => 'required', + 'city' => 'required', + 'country' => 'required', + 'contact_number' => 'required|numeric|digits:10', + 'email_id' => 'required', + 'email_id' => 'required', + // 'no_of_units_you_wish_to_buy' => 'required|numeric', + // 'offer_price_per_unit' => 'required|numeric', + ], [ + 'required' => 'The :attribute field must be required', + 'numeric' => 'The :attribute field must be in digits', + 'digits' => 'The :attribute field must have 10 digits', + ]); + + } + $validationMessage = $this->validationError($validator); @@ -304,8 +342,8 @@ class MarketPlaceController extends Controller 'country' => $request->country, 'contact_number' => $request->contact_number, 'email_id' => $request->email_id, - 'no_of_units_you_wish_to_buy' => $request->no_of_units_you_wish_to_buy, - 'offer_price_per_unit' => $request->offer_price_per_unit, + 'no_of_units_you_wish_to_buy' => $request->no_of_units_you_wish_to_buy ?? 0, + 'offer_price_per_unit' => $request->offer_price_per_unit ?? 0, 'total_purchase_value' => $request->total_purchase_value, ]); if ($buyerForm) { @@ -324,23 +362,41 @@ class MarketPlaceController extends Controller //update form start public function buyerFormSubmitUpdate(Request $request) { - $validator = Validator::make($request->all(), [ - 'marketplaceBuyerFormId' => 'required', - 'id' => 'required', - 'table' => 'required', - 'name' => 'required', - 'city' => 'required', - 'country' => 'required', - 'contact_number' => 'required|numeric|digits:10', - 'email_id' => 'required', - 'no_of_units_you_wish_to_buy' => 'required|numeric', - 'offer_price_per_unit' => 'required|numeric', - ], [ - 'required' => 'The :attribute field must be required', - 'numeric' => 'The :attribute field must be in digits', - 'digits' => 'The :attribute field must have 10 digits', - ]); - + // dd($request->all()); + if ($request->table == 'alternative-investment-funds') + $validator = Validator::make($request->all(), [ + 'marketplaceBuyerFormId' => 'required', + 'id' => 'required', + 'table' => 'required', + 'name' => 'required', + 'city' => 'required', + 'country' => 'required', + 'contact_number' => 'required|numeric|digits:10', + 'email_id' => 'required', + 'no_of_units_you_wish_to_buy' => 'required|numeric', + 'offer_price_per_unit' => 'required|numeric', + ], [ + 'required' => 'The :attribute field must be required', + 'numeric' => 'The :attribute field must be in digits', + 'digits' => 'The :attribute field must have 10 digits', + ]); + else { + $validator = Validator::make($request->all(), [ + 'marketplaceBuyerFormId' => 'required', + 'id' => 'required', + 'table' => 'required', + 'name' => 'required', + 'city' => 'required', + 'country' => 'required', + 'contact_number' => 'required|numeric|digits:10', + 'email_id' => 'required', + 'total_purchase_value' => 'required', + ], [ + 'required' => 'The :attribute field must be required', + 'numeric' => 'The :attribute field must be in digits', + 'digits' => 'The :attribute field must have 10 digits', + ]); + } $validationMessage = $this->validationError($validator); if ($validationMessage) { @@ -358,20 +414,23 @@ class MarketPlaceController extends Controller $productName = \DB::table($table)->where('id', $request->id)->value('security_name'); } - $buyerForm = MarketplaceBuyerForm::where('id',$request->marketplaceBuyerFormId)->update([ - 'users_id' => auth()->guard('users')->user()->id, - 'associated_id' => $request->id, - 'table' => $table, - 'name' => $request->name, - 'city' => $request->city, - 'country' => $request->country, - 'contact_number' => $request->contact_number, - 'email_id' => $request->email_id, - 'no_of_units_you_wish_to_buy' => $request->no_of_units_you_wish_to_buy, - 'offer_price_per_unit' => $request->offer_price_per_unit, - 'total_purchase_value' => $request->total_purchase_value, - ]); - if ($buyerForm) { + $checkAlreadySold = MarketplaceBuyerForm::where(['id' => $request->marketplaceBuyerFormId, 'status' => 'Sold'])->doesntExist(); + if ($checkAlreadySold) { + $buyerForm = MarketplaceBuyerForm::where('id', $request->marketplaceBuyerFormId)->update([ + 'users_id' => auth()->guard('users')->user()->id, + 'associated_id' => $request->id, + 'table' => $table, + 'name' => $request->name, + 'city' => $request->city, + 'country' => $request->country, + 'contact_number' => $request->contact_number, + 'email_id' => $request->email_id, + 'no_of_units_you_wish_to_buy' => $request->no_of_units_you_wish_to_buy ?? 0, + 'offer_price_per_unit' => $request->offer_price_per_unit ?? 0, + 'total_purchase_value' => $request->total_purchase_value, + ]); + if ($buyerForm) { + } $name = auth()->guard('users')->user()->name; $notify['message'] = "$name has Updated a buyer form for $productName!"; $type = 'Buyer Form'; @@ -380,10 +439,12 @@ class MarketPlaceController extends Controller $data->notify(new UserAdmin($notify, $type)); } return response()->json(['status' => 200, 'message' => "Buyer Form Updated For Successfully"]); + } else { + return response()->json(['status' => 400, 'message' => "This product has been already sold to you"]); } return response()->json(['status' => 400, 'message' => "Buyer Form Could Not Be Updated!"]); } - + //update formm end public function buyerFormAPI($slug) { @@ -507,7 +568,7 @@ class MarketPlaceController extends Controller $productName = \DB::table($table)->where('id', $request->id)->value('security_name'); } - $buyerForm = MarketplaceBuyerForm::where('id',$request->marketplaceBuyerFormId)->update([ + $buyerForm = MarketplaceBuyerForm::where('id', $request->marketplaceBuyerFormId)->update([ 'users_id' => $request->user()->id, 'associated_id' => $request->id, 'table' => $table, @@ -552,7 +613,6 @@ class MarketPlaceController extends Controller $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 $offering['total-interested-buyers'] = $this->checkInvestmentInterestedAPI($offering['data'], 'marketplace_fre_sellers')['total-interested-buyers']; - } elseif (MarketplaceAlternativeInvestmentFundSeller::where('slug', $slug)->exists()) { $offering['type'] = 'alternative-investment-funds'; $marketAIF = MarketplaceAlternativeInvestmentFundSeller::where('slug', $slug)->first(); @@ -561,9 +621,8 @@ class MarketPlaceController extends Controller $offering['invested'] = $this->checkInvestmentInterestedAPI($offering['data'], 'marketplace_aif_sellers')['interested-status']; $offering['invested-data'] = $this->checkInvestmentInterestedDataAPI($offering['data'], 'marketplace_aif_sellers')['interested-status-data']; - + $offering['total-interested-buyers'] = $this->checkInvestmentInterestedAPI($offering['data'], 'marketplace_aif_sellers')['total-interested-buyers']; - } elseif (MarketplaceOtherProductsSeller::where('slug', $slug)->exists()) { $offering['type'] = 'other-products'; $marketOP = MarketplaceOtherProductsSeller::where('slug', $slug)->first(); @@ -584,7 +643,7 @@ class MarketPlaceController extends Controller if (request()->user()) { $interestedStatus = MarketplaceBuyerForm::where(['users_id' => request()->user()->id, 'table' => $table, 'associated_id' => $offering->id])->first(); } - return ['interested-status-data' => $interestedStatus ]; + return ['interested-status-data' => $interestedStatus]; } public function checkInvestmentInterestedAPI($offering, $table) diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index c2ca6df..2068f3a 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -293,6 +293,40 @@ class ProfileController extends Controller } } + public function resendOtpForProfileUpdate(Request $request) + { + try{ + $type = $request->type; + $user_id = request()->user()->id; + $credential = $request->credential; + $otp = rand(1000,9999); + // $getUser = User::find($user_id); + if($type == 1) + { + // type 1 for email otp + // $email = $getUser->email; + $mailData = [ + 'title' => 'Mail from Jerichoalternatives.in', + 'body' => 'This is for testing email using smtp.' + ]; + Mail::to($credential)->send(new OtpMail($mailData, $otp)); + UserOtpModel::where('user_id', $user_id)->update(['email_otp'=> $otp, 'expire_at'=>Carbon::now()->addMinutes(2)]); + } + else if($type == 2) + { + // $mobileNumber = $getUser->contact_number; + $this->thirdPartyOTP($credential, $otp); + UserOtpModel::where('user_id', $user_id)->update(['contact_otp'=> $otp,'expire_at'=>Carbon::now()->addMinutes(2)]); + } + return response()->json([ + 'status'=>200, + 'message'=>'OTP has been send', + ]); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage()], 400); + } + } + public function getUser() { try { diff --git a/app/Imports/FractionalRealEstateImport.php b/app/Imports/FractionalRealEstateImport.php index 96e1325..38ccf07 100644 --- a/app/Imports/FractionalRealEstateImport.php +++ b/app/Imports/FractionalRealEstateImport.php @@ -93,9 +93,9 @@ class FractionalRealEstateImport implements ToCollection, WithHeadingRow 'tables_id' => Table::FractionalRealEstateTable, 'categories_id' => $this->category_id, 'total_views' => 0, - 'status' => 1, + // 'status' => 1, 'created_by' => auth()->user()->id, - 'description'=> $row['description'] ?? null, + 'description'=> $row['property_description'] ?? null, ]); $count = FractionalRealEstate::where('property_name_and_location',$row['property_name_and_location'])->count(); FractionalRealEstate::create([ diff --git a/app/Imports/StockFundsRealEstateExchangeImport.php b/app/Imports/StockFundsRealEstateExchangeImport.php index 52d50f3..3449b90 100644 --- a/app/Imports/StockFundsRealEstateExchangeImport.php +++ b/app/Imports/StockFundsRealEstateExchangeImport.php @@ -52,7 +52,7 @@ class StockFundsRealEstateExchangeImport implements ToCollection, WithHeadingRow // { // $name = 'no'; // } - // dd($rows, $name); + // dd($rows); foreach ($rows as $row) { $product = Product::create([ 'tables_id' => Table::StockFundsRealEstateExchangeTable, @@ -62,7 +62,8 @@ class StockFundsRealEstateExchangeImport implements ToCollection, WithHeadingRow 'created_by' => auth()->user()->id, 'description'=> $row['description'] ?? null ]); - $count = StockFundsRealEstateExchange::where('name',$row['stock_name'])->count(); + // $count = StockFundsRealEstateExchange::where('name',$row['stock_name'])->count(); + $count = StockFundsRealEstateExchange::where('name',$row['name'])->count(); // $count = StockFundsRealEstateExchange::where(function($query) use($row){ // $query->orWhere('stock_name'); // $query->orWhere('etf_name'); @@ -74,7 +75,8 @@ class StockFundsRealEstateExchangeImport implements ToCollection, WithHeadingRow 'products_id' => $product->id, // 'slug' => $count < 2 ? Str::slug($row['stock_name'] ?? $row['etf_name'] ?? $row['reit_name']) : Str::slug($row['stock_name'].'-'.$count+1 ?? $row['etf_name'].'-'.$count+1 ?? $row['reit_name'].'-'.$count+1), // 'name' => $row['stock_name'] ?? $row['etf_name'] ?? $row['reit_name'], - 'slug' => $count < 2 ? Str::slug($row['stock_name'] ?? $row['etf_name'] ?? $row['reit_name']) : Str::slug($row['stock_name'].'-'.$count+1 ?? $row['etf_name'].'-'.$count+1 ?? $row['reit_name'].'-'.$count+1), + // 'slug' => $count < 2 ? Str::slug($row['stock_name'] ?? $row['etf_name'] ?? $row['reit_name']) : Str::slug($row['stock_name'].'-'.$count+1 ?? $row['etf_name'].'-'.$count+1 ?? $row['reit_name'].'-'.$count+1), + 'slug' => $count < 2 ? Str::slug($row['name']) : Str::slug($row['name'].'-'.$count+1), 'name' => $row['name'] ?? null, // 'type' => $this->fundType, 'ticker' => $row['ticker'], diff --git a/app/Models/MarketplaceAlternativeInvestmentFundSeller.php b/app/Models/MarketplaceAlternativeInvestmentFundSeller.php index 84682fa..7cd6a0d 100644 --- a/app/Models/MarketplaceAlternativeInvestmentFundSeller.php +++ b/app/Models/MarketplaceAlternativeInvestmentFundSeller.php @@ -21,6 +21,11 @@ class MarketplaceAlternativeInvestmentFundSeller extends Model return $this->belongsTo(MarketplaceSellerForm::class, 'seller_forms_id'); } + public function buyer() + { + return $this->belongsTo(MarketplaceBuyerForm::class, 'seller_forms_id'); + } + public function Sluggable(): array { return [ @@ -126,15 +131,35 @@ class MarketplaceAlternativeInvestmentFundSeller extends Model public function getBidAttribute($id) { - $values = MarketplaceAlternativeInvestmentFundSeller::where('id', $id)->first(); - $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_aif_sellers'])->get(); - $bidArr = []; - foreach ($bids as $bid) { - $bidArr[] = round(($bid->getAttributes()['total_purchase_value'] - $this->current_or_latest_nav) / $this->current_or_latest_nav * 100, 3); + $values = MarketplaceAlternativeInvestmentFundSeller::where('id', $this->id)->first(); + $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_aif_sellers'])->where('status','!=','Sold')->get(); + // $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_aif_sellers'])->get(); + $bidArray = collect(); + $bids->each(function($value) use ($bidArray,$values){ + if($value->no_of_units_you_wish_to_buy < $values->no_of_units_you_wish_to_sell) + { + // $bidArray->push($value->getAttributes()['total_purchase_value']); + $bidArray->push($value->getAttributes()['offer_price_per_unit']); + } + }); + $noOfUnitHeld = (int)$values->current_or_latest_nav; + // $nav = intval($noOfUnitHeld) * intval($values->current_or_latest_nav); + $highestBid = intval($bidArray->max()); + // $bid = ($highestBid - $nav)/(int)$nav * 100 ; + $bid = ($highestBid - $noOfUnitHeld)/(int)$noOfUnitHeld * 100 ; + if(count($bids)) + { + return round($bid,3); } - if ($bidArr) { - return (string)max($bidArr); - } - return (string)0; + + // dd($bids->toArray()); + // $bidArr = []; + // foreach ($bids as $bid) { + // $bidArr[] = round(($bid->getAttributes()['total_purchase_value'] - $this->current_or_latest_nav) / $this->current_or_latest_nav * 100, 3); + // } + // if ($bidArr) { + // return (string)max($bidArr); + // } + return (int)0; } } diff --git a/app/Models/MarketplaceBuyerForm.php b/app/Models/MarketplaceBuyerForm.php index a9430c4..fb3eced 100644 --- a/app/Models/MarketplaceBuyerForm.php +++ b/app/Models/MarketplaceBuyerForm.php @@ -89,4 +89,11 @@ class MarketplaceBuyerForm extends Model public function company(){ return $this->belongsTo(Company::class,'platform'); } + + public function freSellerData(){ + return $this->hasOne(MarketplaceFractionalRealEstateSeller::class,'id','associated_id'); + } + public function aifSellerData(){ + return $this->hasOne(MarketplaceAlternativeInvestmentFundSeller::class,'id','associated_id'); + } } diff --git a/app/Models/MarketplaceFractionalRealEstateSeller.php b/app/Models/MarketplaceFractionalRealEstateSeller.php index 91e12bd..4415b3f 100644 --- a/app/Models/MarketplaceFractionalRealEstateSeller.php +++ b/app/Models/MarketplaceFractionalRealEstateSeller.php @@ -19,6 +19,10 @@ class MarketplaceFractionalRealEstateSeller extends Model public function seller(){ return $this->belongsTo(MarketplaceSellerForm::class,'seller_forms_id'); } + + public function buyer(){ + return $this->belongsTo(MarketplaceBuyerForm::class,'seller_forms_id'); + } public function company(){ return $this->belongsTo(Company::class,'fractional_real_estate_platform'); @@ -48,7 +52,7 @@ class MarketplaceFractionalRealEstateSeller extends Model public function getBidAttribute($id){ $values = MarketplaceFractionalRealEstateSeller::where('id', $this->id)->first(); - $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_fre_sellers'])->get(); + $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_fre_sellers'])->where('status','!=','Sold')->get(); $bidArr = []; foreach($bids as $bid){ $bidArr[] = round(($bid->getAttributes()['total_purchase_value'] - $this->current_market_value_of_the_property)/$this->current_market_value_of_the_property * 100,3); @@ -61,24 +65,25 @@ class MarketplaceFractionalRealEstateSeller extends Model public function getSoldStatusAttribute($id) { - return MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->exists() ? 'SOLD' : 'OPEN'; - // $buyerData = MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->get(); + // return MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->exists() ? 'SOLD' : 'OPEN'; + // dd($id); + // $buyerData = MarketplaceBuyerForm::where('associated_id', $this->id)->where('status', 'Sold')->get(); // $totalSellUnits = 0; // $buyerData->each(function($data) use($totalSellUnits){ // return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy; // }); - // if(MarketplaceFractionalRealEstateSeller::where('id',$buyerData->associated_id)->exists()) - // { - // $getAIFData = MarketplaceFractionalRealEstateSeller::where('id',$buyerData->associated_id)->first(); - // $aifData = (int)$getAIFData->no_of_units_you_wish_to_sell; - // $remainUnits = $aifData - $totalSellUnits; - // if($remainUnits < 0) - // { - // return 'SOLD'; - // } - // return 'OPEN'; - // }else{ - // return 'OPEN'; - // } + if(MarketplaceFractionalRealEstateSeller::where('id',$id)->exists()) + { + $getFREData = MarketplaceFractionalRealEstateSeller::where('id',$id)->first(); + // $aifData = (int)$getFREData->no_of_units_you_wish_to_sell; + // $remainUnits = $aifData - $totalSellUnits; + if($getFREData->current_market_value_of_the_property < 0) + { + return 'SOLD'; + } + return 'OPEN'; + }else{ + return 'OPEN'; + } } } \ No newline at end of file diff --git a/app/Models/Product.php b/app/Models/Product.php index 8fcaadd..e94772d 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -18,7 +18,7 @@ class Product extends Model protected $hidden = ['tables_id', 'total_views', 'created_by', 'modified_by', 'updated_at', 'deleted_at']; - protected $fillable = ['tables_id', 'categories_id', 'total_views', 'status', 'top_pick', 'created_by', 'modified_by', 'presentation', 'fact_sheet', 'type', 'profit_sharing', 'upfront_rate', 'trail_rate', 'gst', 'tds', 'end_of_trail', 'channel_partner_aggrement']; + protected $fillable = ['tables_id', 'description', 'categories_id', 'total_views', 'status', 'top_pick', 'created_by', 'modified_by', 'presentation', 'fact_sheet', 'type', 'profit_sharing', 'upfront_rate', 'trail_rate', 'gst', 'tds', 'end_of_trail', 'channel_partner_aggrement']; // public function companies(){ // return $this->belongsTo(Company::class,'id','companies_id'); @@ -405,7 +405,8 @@ class Product extends Model $products = $query->select(\DB::raw('products.id,coalesce(fre.property_name_and_location,aif.fund_name,bd.issuer,fd.fund_name,exchange.name,re.property_name) as product_name'), 'products.categories_id as categories_id', 'categories.category_name', 'top_pick', 'fre.property_image', 'company_logo', 'file_name', \DB::raw('coalesce(fre.geographic_focus,aif.geographic_focus,bd.geographic_focus,fd.geographic_focus,exchange.geographic_focus,re.geographic_focus) as geographic_focus'), \DB::raw('coalesce(fre.minimum_investment,aif.minimum_capital_commitment,bd.minimum_investment,fd.minimum_investment,re.total_price) as minimum_investment'), \DB::raw('coalesce(fre.slug,aif.slug,bd.slug,fd.slug,re.slug,exchange.slug) as slug'), // \DB::raw('coalesce(fre.property_description,aif.description,bd.about_issuer,fd.fund_description,exchange.about,re.remarks) as description') - 'products.description' + \DB::raw('coalesce(products.description) as description') + // 'products.description' ) ->leftJoin('fractional_real_estates as fre', 'products.id', 'fre.products_id') ->leftJoin('alternative_investment_funds as aif', 'products.id', 'aif.products_id') diff --git a/app/Services/Frontend/GlobalRealEstateService.php b/app/Services/Frontend/GlobalRealEstateService.php index ddeba91..c6bb1d8 100644 --- a/app/Services/Frontend/GlobalRealEstateService.php +++ b/app/Services/Frontend/GlobalRealEstateService.php @@ -33,12 +33,12 @@ class GlobalRealEstateService{ public function fullyFundedGCRE() { - return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalCommercialRealEstate()->open()->active()->get()); + return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalCommercialRealEstate()->fullyFunded()->active()->get()); } public function resaleGCRE() { - return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalCommercialRealEstate()->open()->active()->get()); + return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalCommercialRealEstate()->resale()->active()->get()); } public function openGRRE() @@ -48,12 +48,12 @@ class GlobalRealEstateService{ public function fullyFundedGRRE() { - return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalResidentialRealEstate()->open()->active()->get()); + return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalResidentialRealEstate()->fullyFunded()->active()->get()); } public function resaleGRRE() { - return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalResidentialRealEstate()->open()->active()->get()); + return $this->returnResponse(Product::has('realEstate')->with('realEstate','categorys')->globalResidentialRealEstate()->resale()->active()->get()); } public function globalCommercialRealEstateLearnMore(){ diff --git a/app/helper.php b/app/helper.php index 9db5ea3..0923007 100644 --- a/app/helper.php +++ b/app/helper.php @@ -394,6 +394,11 @@ function getCategoryIcons($categoryId) "public/assets/media/FrontendImages/resi-real-state.svg" => Category::GlobalResidentialRealEstateID, "public/assets/media/FrontendImages/comm-real-state.svg" => Category::GlobalCommercialRealEstateID, ]; + + if ($categoryId === Category::PrivateEquityFundId) { + return "public/assets/media/FrontendImages/equity-funds.svg"; + } $condition = array_search($categoryId, $category_icons); + // return $condition; return $condition == true ? $condition : 'public/assets/media/FrontendImages/bay-arrow.svg'; } diff --git a/public/assets/css/FrontendCss/style.css b/public/assets/css/FrontendCss/style.css index e54ec53..0c325cb 100644 --- a/public/assets/css/FrontendCss/style.css +++ b/public/assets/css/FrontendCss/style.css @@ -485,7 +485,7 @@ h4.inner-title { .assets-card .middle-sec { display: flex; background-color: #e8c69f; - padding:8px 7px; + padding: 8px 7px; align-items: center; justify-content: space-between; } @@ -4601,6 +4601,18 @@ button.swal2-confirm.btn.btn-primary.popup-button { background-color: #c18948 !important; border: none; } +#exampleModalCenter button.close { + border: none; + background-color: transparent; + font-size: 29px; +} +#exampleModalCenter .modal-header.p-2 { + display: flex; + justify-content: end; +} +#exampleModalCenter .modal-content a.yellow-btn { + height: 42px; +} #exampleModalCenter button.btn.btn-secondary { background-color: #1b243d; } diff --git a/public/excel-template/RealEstateInvestmentTrustsTemplate.xlsx b/public/excel-template/RealEstateInvestmentTrustsTemplate.xlsx index 2c4a5da..b5cf12e 100644 Binary files a/public/excel-template/RealEstateInvestmentTrustsTemplate.xlsx and b/public/excel-template/RealEstateInvestmentTrustsTemplate.xlsx differ 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 53999da..a9073e5 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 @@ -61,23 +61,23 @@