Edit your investment's today!
--
-
- Verified Buyers -
- Expert Verification -
- Sell From Your Home -
--}}
- diff --git a/app/Http/Controllers/Admin/OverviewController.php b/app/Http/Controllers/Admin/OverviewController.php index 31dee97..1d5d6cd 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 ]); diff --git a/app/Http/Controllers/Frontend/MarketPlaceController.php b/app/Http/Controllers/Frontend/MarketPlaceController.php index e7198ff..fd4348c 100644 --- a/app/Http/Controllers/Frontend/MarketPlaceController.php +++ b/app/Http/Controllers/Frontend/MarketPlaceController.php @@ -75,7 +75,7 @@ class MarketPlaceController extends Controller // $marketplaceListed = []; - + return [ @@ -121,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) @@ -172,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){ @@ -184,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'; @@ -212,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) @@ -231,7 +243,7 @@ class MarketPlaceController extends Controller public function buyerForm($slug) { $offering = $this->viewOfferingData($slug); - + $table = $offering['type']; $id = $offering['data']->id; $userData = array(); @@ -259,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); @@ -306,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) { @@ -326,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) { @@ -360,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'; @@ -382,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) { @@ -509,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, @@ -554,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(); @@ -563,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(); @@ -586,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/Models/MarketplaceFractionalRealEstateSeller.php b/app/Models/MarketplaceFractionalRealEstateSeller.php index 28ac5ae..029ba39 100644 --- a/app/Models/MarketplaceFractionalRealEstateSeller.php +++ b/app/Models/MarketplaceFractionalRealEstateSeller.php @@ -61,18 +61,19 @@ 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(); - $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()) + // 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',$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) + $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'; } diff --git a/public/assets/css/FrontendCss/style.css b/public/assets/css/FrontendCss/style.css index 2a91d82..19844f5 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; +} /*======responsive=====*/ diff --git a/resources/views/Frontend/Pages/marketplace/view-offering.blade.php b/resources/views/Frontend/Pages/marketplace/view-offering.blade.php index 5e410b4..2ec37bd 100644 --- a/resources/views/Frontend/Pages/marketplace/view-offering.blade.php +++ b/resources/views/Frontend/Pages/marketplace/view-offering.blade.php @@ -70,14 +70,14 @@ aria-hidden="true">