2024-03-28 14:52:40 +05:30
< ? php
namespace App\Http\Controllers\Admin ;
use Mail ;
use App\Models\User ;
use App\Models\Company ;
2024-07-04 13:34:21 +05:30
use App\Mail\SentBuyerMail ;
2024-03-28 14:52:40 +05:30
use Illuminate\Http\Request ;
use App\Notifications\UserAdmin ;
use App\Models\Admin\BuyerSentMail ;
use App\Models\MarketplaceBuyerForm ;
use App\Http\Controllers\Controller ;
use App\Models\MarketplaceSellerForm ;
use Illuminate\Support\Facades\Validator ;
use App\Models\MarketplaceOtherProductsSeller ;
use App\Models\MarketplaceFractionalRealEstateSeller ;
use App\Models\MarketplaceAlternativeInvestmentFundSeller ;
2024-04-24 15:20:53 +05:30
use App\Exports\InvestmentExport ;
use Excel ;
2024-03-28 14:52:40 +05:30
class OverviewController extends Controller
{
public function index ()
{
2024-04-09 17:56:07 +05:30
$check = checkSidebarAccess ( 'overview' );
if ( ! $check ) {
abort ( 404 );
}
2024-03-28 14:52:40 +05:30
$totalSellerProfile = MarketplaceSellerForm :: count ();
$completedTransactions = MarketplaceBuyerForm :: where ( 'status' , 'Sold' ) -> count ();
$totalInvestmentListed = MarketplaceAlternativeInvestmentFundSeller :: count () + MarketplaceFractionalRealEstateSeller :: count () + MarketplaceOtherProductsSeller :: count ();
$aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller :: where ( 'status' , 'Approved' ) -> latest () -> get ();
$freMarketPlace = MarketplaceFractionalRealEstateSeller :: where ( 'status' , 'Approved' ) -> latest () -> get ();
2024-04-25 11:40:12 +05:30
// dd($freMarketPlace);
2024-03-28 14:52:40 +05:30
$opMarketPlace = MarketplaceOtherProductsSeller :: where ( 'status' , 'Approved' ) -> latest () -> get ();
2024-04-24 15:20:53 +05:30
$allMarketPlace = collect ();
2024-07-04 13:34:21 +05:30
foreach ( $aifMarketPlace as $data ) {
2024-04-24 15:20:53 +05:30
$data -> table = 'marketplace_aif_sellers' ;
$allMarketPlace -> push ( $data );
}
2024-07-04 13:34:21 +05:30
foreach ( $freMarketPlace as $data ) {
2024-04-24 15:20:53 +05:30
$data -> table = 'marketplace_fre_sellers' ;
$allMarketPlace -> push ( $data );
}
2024-07-04 13:34:21 +05:30
2024-04-24 15:20:53 +05:30
$allMarketPlace = $allMarketPlace -> sortByDesc ( 'created_at' );
// dd($allMarketPlace);
2024-07-04 13:34:21 +05:30
return view ( 'Admin.Pages.pre_owned_investment.pre_owned_investment' , compact ( 'aifMarketPlace' , 'freMarketPlace' , 'opMarketPlace' , 'totalSellerProfile' , 'completedTransactions' , 'totalInvestmentListed' , 'allMarketPlace' ));
2024-04-24 15:20:53 +05:30
}
public function downloadInvestment ()
{
2024-07-04 13:34:21 +05:30
2024-04-24 15:20:53 +05:30
// $aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller::with(['seller' => function($query){$query->select('name as SellerName','email as Email','contact_number as Contact')->get();}])->where('status', 'Approved')->latest()->select('name_of_the_aif_fund as Product','expected_sale_per_unit as ExpectedSellingPrice','listing_status as ListingStatus')->get();
$aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' ) -> where ( 'status' , 'Approved' ) -> latest () -> get ();
$freMarketPlace = MarketplaceFractionalRealEstateSeller :: with ( 'seller' ) -> where ( 'status' , 'Approved' ) -> latest () -> get ();
// $aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller::with('seller')->where('status', 'Approved')->latest()->get();
// $freMarketPlace = MarketplaceFractionalRealEstateSeller::with('seller')->where('status', 'Approved')->latest()->get();
$allMarketPlace = collect ();
$newData = [];
$count = 0 ;
2024-07-04 13:34:21 +05:30
foreach ( $aifMarketPlace as $data ) {
2024-04-24 15:20:53 +05:30
// $data['table'] = 'marketplace_aif_sellers';
// $newData[$count]['Product'] = $data->name_of_the_aif_fund;
// $newData[$count]['ExpectedSellingPrice'] = $data->expected_sale_per_unit ;
// $newData[$count]['SellerName'] = $data->seller->name;
// $newData[$count]['Email'] = $data->seller->email;
// $newData[$count]['Contact'] = $data->seller->contact_number;
// $newData[$count]['ListingStatus'] = $data->listing_status;
// $newData[$count]['CreatedAt'] = $data->created_at->format('F d, o');
$newData = array (
" Product " => $data -> name_of_the_aif_fund ,
" ExpectedSellingPrice " => $data -> expected_sale_per_unit ,
" SellerName " => $data -> seller -> name ,
" Email " => $data -> seller -> email ,
" Contact " => $data -> seller -> contact_number ,
" ListingStatus " => $data -> listing_status ,
" CreatedAt " => $data -> created_at -> format ( 'F d, o' )
);
$allMarketPlace -> push ( $newData );
$count ++ ;
}
2024-07-04 13:34:21 +05:30
foreach ( $freMarketPlace as $data ) {
2024-04-24 15:20:53 +05:30
// $newData[$count]['Product'] = $data->property_name;
// $newData[$count]['ExpectedSellingPrice'] = $data->expected_selling_price ;
// $newData[$count]['SellerName'] = $data->seller->name;
// $newData[$count]['Email'] = $data->seller->email;
// $newData[$count]['Contact'] = $data->seller->contact_number;
// $newData[$count]['ListingStatus'] = $data->listing_status;
// $newData[$count]['CreatedAt'] = $data->created_at->format('F d, o');
$newData = array (
" Product " => $data -> property_name ,
2024-07-04 13:34:21 +05:30
" ExpectedSellingPrice " => $data -> expected_selling_price ,
2024-04-24 15:20:53 +05:30
" SellerName " => $data -> seller -> name ,
" Email " => $data -> seller -> email ,
" Contact " => $data -> seller -> contact_number ,
" ListingStatus " => $data -> listing_status ,
" CreatedAt " => $data -> created_at -> format ( 'F d, o' )
);
$allMarketPlace -> push ( $newData );
$count ++ ;
}
// dd($allMarketPlace->sortByDesc('created_at'));
// return $allMarketPlace->sortByDesc('created_at');
// dd($allMarketPlace);
return Excel :: download ( new InvestmentExport ( $allMarketPlace ), 'investmentExport.xlsx' );
2024-03-28 14:52:40 +05:30
}
public function interestedBuyers ( $id , $table )
{
2024-07-04 13:34:21 +05:30
$interestedBuyers = MarketplaceBuyerForm :: where ([ 'associated_id' => $id , 'table' => $table ]) -> orderBy ( 'updated_at' , 'DESC' ) -> get ();
2024-03-28 14:52:40 +05:30
if ( $table == 'marketplace_fre_sellers' ) {
$data = MarketplaceFractionalRealEstateSeller :: with ( 'seller' ) -> where ( 'id' , $id ) -> firstOrFail ();
} elseif ( $table == 'marketplace_aif_sellers' ) {
$data = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' ) -> where ( 'id' , $id ) -> firstOrFail ();
} elseif ( $table == 'marketplace_op_sellers' ) {
$data = MarketplaceOtherProductsSeller :: with ( 'seller' ) -> where ( 'id' , $id ) -> firstOrFail ();
} else {
abort ( 404 );
}
$backId = $id ;
$backTable = $table ;
2024-05-09 12:58:13 +05:30
// dd($backTable);
2024-03-28 14:52:40 +05:30
return view ( 'Admin.Pages.pre_owned_investment.interested-buyers' , compact ( 'interestedBuyers' , 'data' , 'backId' , 'backTable' ));
}
public function listingFeaturedStatus ( Request $request )
{
2024-04-16 15:17:56 +05:30
// dd($request->all());
2024-03-28 14:52:40 +05:30
$listingStatus = $request -> listing_status ;
$id = $request -> id ;
$table = $request -> table ;
if ( ! ( $table == 'marketplace_aif_sellers' || $table == 'marketplace_fre_sellers' || $table == 'marketplace_op_sellers' )) {
abort ( 404 );
}
if ( $listingStatus == 'Spotlight' ) {
$checkSpotlightExists = MarketplaceFractionalRealEstateSeller :: where ( 'listing_status' , 'Spotlight' ) -> exists () || MarketplaceAlternativeInvestmentFundSeller :: where ( 'listing_status' , 'Spotlight' ) -> exists () || MarketplaceOtherProductsSeller :: where ( 'listing_status' , 'Spotlight' ) -> exists ();
if ( $checkSpotlightExists ) {
return response () -> json ([ 'status' => 400 , 'message' => 'An Investment Already Listed With Spotlight!' ]);
}
}
$data = \DB :: table ( $table ) -> join ( 'marketplace_seller_forms' , $table . '.seller_forms_id' , 'marketplace_seller_forms.id' ) -> where ( $table . '.id' , $id ) -> first ();
$changeListingStatus = \DB :: table ( $table ) -> where ( 'id' , $id ) -> update ([
'listing_status' => $listingStatus
]);
2024-04-16 15:17:56 +05:30
// if ($changeListingStatus && $listingStatus != 'Hide') {
if ( $listingStatus != 'Hide' ) {
2024-07-04 13:34:21 +05:30
if ( $listingStatus != 'Non-Featured' ) {
2024-04-16 15:17:56 +05:30
$user = User :: find ( $data -> users_id );
$productName = $data -> security_name ? ? $data -> property_name ? ? $data -> name_of_the_aif_fund ;
$notify [ 'message' ] = " Congratulations, Your investment( $productName ) has been assigned to $listingStatus section! " ;
$user -> notify ( new UserAdmin ( $notify ));
return response () -> json ([ 'status' => 200 , 'message' => 'Listing Status Changed!' ]);
}
2024-03-28 14:52:40 +05:30
}
2024-04-16 15:17:56 +05:30
// dd($changeListingStatus);
// return response()->json(['status' => 400, 'message' => 'Error Changing Listing Status!']);
return response () -> json ([ 'status' => 200 , 'message' => 'Listing Status Changed!' ]);
2024-03-28 14:52:40 +05:30
}
public function changeStatusBuyer ( Request $request )
{
$status = $request -> status ;
$buyerId = $request -> buyer_id ;
// if ($status == 'Sold') {
// $alreadySold = MarketplaceBuyerForm::where('status', 'Sold')->exists();
// if ($alreadySold) {
// return response()->json(['status' => 400, 'message' => 'This product has already been Sold']);
// }
// }
2024-05-16 11:53:28 +05:30
// $checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->exists();
// if(!$checkAlreadySold)
// {
2024-04-26 12:23:43 +05:30
// $marketPlaceId = $checkAlreadySold->associated_id;
// if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
// {
// $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first();
// $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
// $newUnits = (int)$checkAlreadySold->no_of_units_you_wish_to_buy + $oldUnit;
// $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
// 'no_of_units_you_wish_to_sell' => $newUnits,
// ]);
2024-07-04 13:34:21 +05:30
2024-04-26 12:23:43 +05:30
// }
// // elseif(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists())
// // {
// // $getAIFData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first();
// // $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
// // $newUnits = (int)$checkAlreadySold->no_of_units_you_wish_to_buy + $oldUnit;
// // $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
// // 'no_of_units_you_wish_to_sell' => $newUnits,
// // ]);
// // }
// }else
2024-07-04 13:34:21 +05:30
2024-05-07 16:45:56 +05:30
// dd($request->all());
2024-06-25 15:21:21 +05:30
// $userID .= '';F
$product_name = '' ;
$getMarketplaceBuyerUnit = MarketplaceBuyerForm :: where ( 'id' , $buyerId ) -> first ();
// $userID .= $getMarketplaceBuyerUnit->user_id;
$marketPlaceId = $getMarketplaceBuyerUnit -> associated_id ;
$getUnits = ( int ) $getMarketplaceBuyerUnit -> no_of_units_you_wish_to_buy ? ? 0 ;
$getBuyingPurchaseValue = ( int ) $getMarketplaceBuyerUnit -> getAttributes ()[ 'total_purchase_value' ];
2024-07-04 13:34:21 +05:30
if ( MarketplaceAlternativeInvestmentFundSeller :: where ( 'id' , $marketPlaceId ) -> exists () && $getMarketplaceBuyerUnit -> table == 'marketplace_aif_sellers' ) {
$getAIFData = MarketplaceAlternativeInvestmentFundSeller :: where ( 'id' , $marketPlaceId ) -> first ();
2024-06-25 15:21:21 +05:30
$product_name .= $getAIFData -> name_of_the_aif_fund ;
2024-07-04 13:34:21 +05:30
if ( $status == 'Sold' ) {
2024-06-25 15:21:21 +05:30
$oldUnit = ( int ) $getAIFData -> no_of_units_you_wish_to_sell ;
$newUnits = $oldUnit - ( int ) $getUnits ;
2024-07-04 13:34:21 +05:30
if ( $newUnits >= 0 ) {
$updateUnits = MarketplaceAlternativeInvestmentFundSeller :: where ( 'id' , $marketPlaceId ) -> update ([
2024-06-25 15:21:21 +05:30
'no_of_units_you_wish_to_sell' => $newUnits ,
]);
2024-07-04 13:34:21 +05:30
} else {
return response () -> json ([ 'status' => 400 , 'message' => 'Bid units is more than seller units with ' . abs ( $newUnits ) . ' units' ]);
2024-06-25 15:21:21 +05:30
}
}
2024-07-04 13:34:21 +05:30
} else if ( MarketplaceFractionalRealEstateSeller :: where ( 'id' , $marketPlaceId ) -> exists () && $getMarketplaceBuyerUnit -> table == 'marketplace_fre_sellers' ) {
2024-06-25 15:21:21 +05:30
// dd('inside');
2024-07-04 13:34:21 +05:30
$getFREData = MarketplaceFractionalRealEstateSeller :: where ( 'id' , $marketPlaceId ) -> first ();
2024-06-25 15:21:21 +05:30
$product_name .= $getFREData -> property_name ;
2024-07-04 13:34:21 +05:30
if ( $status == 'Sold' ) {
if (( int ) $getFREData -> current_market_value_of_the_property <= 0 ) {
2024-06-25 15:21:21 +05:30
return response () -> json ([ 'status' => 400 , 'message' => 'Product cannot be sold. because product has no value.' ]);
}
$freValue = ( int ) $getFREData -> current_market_value_of_the_property ;
$nowValue = $freValue - $getBuyingPurchaseValue ;
2024-05-07 17:26:06 +05:30
2024-06-25 15:21:21 +05:30
$percentage = ( $freValue - $getBuyingPurchaseValue ) / $freValue * 100 ;
2024-05-07 17:26:06 +05:30
2024-06-25 15:21:21 +05:30
$expectedSellingPrice = ( int ) $getFREData -> expected_selling_price ;
$updateExpectedSellingPrice = $expectedSellingPrice * ( $percentage / 100 );
// dd($percentage,$updateExpectedSellingPrice);
2024-07-04 13:34:21 +05:30
if ( $nowValue <= 0 ) {
$updatePrice = MarketplaceFractionalRealEstateSeller :: where ( 'id' , $marketPlaceId ) -> update ([
2024-06-25 15:21:21 +05:30
'current_market_value_of_the_property' => 0 ,
'expected_selling_price' => 0 ,
2024-07-04 13:34:21 +05:30
]);
} else if ( $nowValue > 0 ) {
$updatePrice = MarketplaceFractionalRealEstateSeller :: where ( 'id' , $marketPlaceId ) -> update ([
2024-06-25 15:21:21 +05:30
'current_market_value_of_the_property' => $nowValue ,
'expected_selling_price' => $updateExpectedSellingPrice ,
2024-07-04 13:34:21 +05:30
]);
2024-04-26 12:23:43 +05:30
}
2024-05-07 16:45:56 +05:30
}
2024-06-25 15:21:21 +05:30
// else{
// return response()->json(['status' => 400, 'message' => 'Bid price is more than seller price with ₹'.abs($nowValue)]);
// }
}
$user = User :: find ( $getMarketplaceBuyerUnit -> users_id );
// $productName = $data->security_name ?? $data->property_name ?? $data->name_of_the_aif_fund;
$notify [ 'message' ] = " Your BID status for ( $product_name ) product has been changed to $status ! " ;
$user -> notify ( new UserAdmin ( $notify ));
2024-07-04 13:34:21 +05:30
// dd('outside');
2024-06-25 15:21:21 +05:30
// }
2024-07-04 13:34:21 +05:30
// $user = User::find($userID);
// // $productName = $data->security_name ?? $data->property_name ?? $data->name_of_the_aif_fund;
// $notify['message'] = "Your BID status for ($product_name) product has been changed to $status !";
// $user->notify(new UserAdmin($notify));
2024-05-16 11:53:28 +05:30
// }
2024-05-07 16:45:56 +05:30
// dd('hello');
2024-03-28 14:52:40 +05:30
$alreadySold = MarketplaceBuyerForm :: where ( 'id' , $buyerId ) -> update ([
'status' => $status
]);
2024-06-25 15:21:21 +05:30
2024-07-04 13:34:21 +05:30
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Status Changed!' ]);
}
public function listingTransfer ()
{
2024-05-08 18:35:30 +05:30
$check = checkSidebarAccess ( 'investment-`listing-transfer`' );
2024-04-09 17:56:07 +05:30
if ( ! $check ) {
abort ( 404 );
}
2024-04-04 19:47:22 +05:30
// $freMarketPlace = MarketplaceFractionalRealEstateSeller::with('seller')->orderBy('created_at', 'desc')->get();
// $aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller::with('seller')->orderBy('created_at', 'desc')->get();
// $opMarketPlace = MarketplaceOtherProductsSeller::with('seller')->orderBy('created_at', 'desc')->get();
2024-03-28 14:52:40 +05:30
// dd($aifMarketPlace[29]);
2024-04-04 19:47:22 +05:30
//new by hritik
$freMarketPlace = MarketplaceFractionalRealEstateSeller :: with ( 'seller' ) -> orderBy ( 'created_at' , 'desc' ) -> get ();
$aifMarketPlace = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' ) -> orderBy ( 'created_at' , 'desc' ) -> get ();
$opMarketPlace = MarketplaceOtherProductsSeller :: with ( 'seller' ) -> orderBy ( 'created_at' , 'desc' ) -> get ();
2024-04-09 17:56:07 +05:30
2024-04-04 19:47:22 +05:30
$combinedData = collect ();
foreach ( $freMarketPlace as $freData ) {
$freData -> table = 'marketplace_fre_sellers' ;
$combinedData -> push ( $freData );
}
foreach ( $aifMarketPlace as $aifData ) {
$aifData -> table = 'marketplace_aif_sellers' ;
$combinedData -> push ( $aifData );
}
foreach ( $opMarketPlace as $opData ) {
$opData -> table = 'marketplace_op_sellers' ;
$combinedData -> push ( $opData );
}
2024-04-09 17:56:07 +05:30
2024-04-04 19:47:22 +05:30
$combinedData = $combinedData -> sortByDesc ( 'created_at' );
2024-04-09 17:56:07 +05:30
2024-04-04 19:47:22 +05:30
//new end
// dd($combinedData);
2024-04-09 17:56:07 +05:30
return view (
'Admin.Pages.pre_owned_investment.pre_owned_investmentV2' ,
compact ( 'freMarketPlace' , 'aifMarketPlace' , 'opMarketPlace' , 'combinedData' )
);
2024-03-28 14:52:40 +05:30
}
public function listingDetails ( $id , $table )
{
$table = [
'marketplace_fre_sellers' => 1 ,
'marketplace_aif_sellers' => 2 ,
'marketplace_op_sellers' => 3 ,
][ $table ];
if ( $table == 1 ) {
$data = MarketplaceFractionalRealEstateSeller :: with ( 'seller' , 'company' ) -> where ( 'id' , $id ) -> firstOrFail ();
2024-05-16 18:45:41 +05:30
$tableName = 'marketplace_fre_sellers' ;
2024-03-28 14:52:40 +05:30
} elseif ( $table == 2 ) {
$data = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' ) -> where ( 'id' , $id ) -> firstOrFail ();
2024-05-16 18:45:41 +05:30
$tableName = 'marketplace_aif_sellers' ;
2024-03-28 14:52:40 +05:30
} elseif ( $table == 3 ) {
$data = MarketplaceOtherProductsSeller :: with ( 'seller' ) -> where ( 'id' , $id ) -> firstOrFail ();
}
2024-07-04 13:34:21 +05:30
$anyOneBuyed = MarketplaceBuyerForm :: where ([ 'associated_id' => $id , 'table' => $tableName ]) -> exists ();
2024-05-15 14:39:18 +05:30
// dd($data);
2024-03-28 14:52:40 +05:30
2024-07-04 13:34:21 +05:30
return view ( 'Admin.Pages.pre_owned_investment.pending_investment_view' , compact ( 'data' , 'table' , 'anyOneBuyed' ));
2024-03-28 14:52:40 +05:30
}
public function listingStatus ( Request $request )
{
$table = [
'marketplace_fre_sellers' => 1 ,
'marketplace_aif_sellers' => 2 ,
'marketplace_op_sellers' => 3 ,
][ $request -> table ];
if ( $table == 1 ) {
MarketplaceFractionalRealEstateSeller :: where ( 'id' , $request -> id ) -> update ([ 'status' => $request -> status ]);
$userId = MarketplaceFractionalRealEstateSeller :: with ( 'seller' ) -> where ( 'id' , $request -> id ) -> firstOrFail ();;
} elseif ( $table == 2 ) {
MarketplaceAlternativeInvestmentFundSeller :: where ( 'id' , $request -> id ) -> update ([ 'status' => $request -> status ]);
$userId = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' ) -> where ( 'id' , $request -> id ) -> firstOrFail ();;
} elseif ( $table == 3 ) {
MarketplaceOtherProductsSeller :: where ( 'id' , $request -> id ) -> update ([ 'status' => $request -> status ]);
$userId = MarketplaceOtherProductsSeller :: with ( 'seller' ) -> where ( 'id' , $request -> id ) -> firstOrFail ();;
}
if ( ! $table ) {
return response () -> json ([ 'status' => 400 , 'message' => 'Error Changing status' ]);
}
if ( $request -> status != 'Pending' ) {
$user = User :: find ( $userId -> seller -> users_id );
$productName = $userId -> property_name ? ? $userId -> name_of_the_aif_fund ? ? $userId -> security_name ;
$notify [ 'message' ] = " Your Investment( $productName ) has been $request->status for marketplace listing! " ;
$user -> notify ( new UserAdmin ( $notify ));
}
return response () -> json ([ 'status' => 200 , 'message' => 'Status Changed' ]);
}
public function total_investment_on_sale ()
{
return view ( 'Admin.Pages.pre_owned_investment.total_investment_on_sale' );
}
public function transactions ()
{
2024-04-09 17:56:07 +05:30
$check = checkSidebarAccess ( 'completed-transaction' );
if ( ! $check ) {
abort ( 404 );
}
2024-05-08 17:46:59 +05:30
// $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();
2024-07-04 13:34:21 +05:30
$marketPlaceBuyerFrom = MarketplaceBuyerForm :: where ( 'status' , 'Sold' ) -> get ();
2024-05-08 17:46:59 +05:30
$newData = collect ();
2024-07-04 13:34:21 +05:30
foreach ( $marketPlaceBuyerFrom as $item ) {
if ( $item -> table == 'marketplace_fre_sellers' ) {
$item [ 'data' ] = MarketplaceFractionalRealEstateSeller :: with ( 'seller.users' , 'company' ,) -> where ( 'id' , $item -> associated_id ) -> first ();
2024-05-08 17:46:59 +05:30
$newData -> push ( $item );
2024-05-30 19:06:30 +05:30
// dd( $item['data']);
2024-07-04 13:34:21 +05:30
} else if ( $item -> table == 'marketplace_aif_sellers' ) {
$item [ 'data' ] = MarketplaceAlternativeInvestmentFundSeller :: with ( 'seller' , 'company' ,) -> where ( 'id' , $item -> associated_id ) -> first ();
2024-05-08 17:46:59 +05:30
$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');
2024-05-02 13:18:17 +05:30
2024-03-28 14:52:40 +05:30
$companies = Company :: active () -> pluck ( 'company_name' , 'id' );
2024-05-15 19:30:22 +05:30
// dd($newData[0]);
2024-05-08 17:46:59 +05:30
// return view('Admin.Pages.pre_owned_investment.transactions', compact('aifBuyerForm', 'freBuyerForm', 'opBuyerForm', 'companies','newData'));
2024-07-04 13:34:21 +05:30
return view ( 'Admin.Pages.pre_owned_investment.transactions' , compact ( 'companies' , 'newData' ));
2024-03-28 14:52:40 +05:30
}
// public function manage_seller_profile()
// {
// return view('Admin.Pages.pre_owned_investment.manage_seller_profile');
// }
public function approved_investment_view ( $id )
{
$id = $id ;
return view ( 'Admin.Pages.pre_owned_investment.approved_investment_view' , compact ( 'id' ));
}
public function replyMail ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'subject' => 'required' ,
'reply' => 'required' ,
], [
'required' => " This :attribute field is required " ,
]);
$validate = validationErrorMessage ( $validator );
if ( $validate ) {
return response () -> json ([ 'status' => 400 , 'message' => $validate ]);
}
$data [ 'subject' ] = $request -> subject ;
$data [ 'message' ] = $request -> reply ;
$email = $request -> email_send ;
Mail :: to ( $email ) -> send ( new SentBuyerMail ( $data ));
$sendData = BuyerSentMail :: create ([
'subject' => $request -> subject ,
'content' => $request -> reply ,
'sent_by' => auth () -> user () -> id ,
'marketplace_buyer_forms_id' => $request -> marketplace_buyer_form_id ,
]);
if ( $sendData ) {
return response () -> json ([ 'status' => 200 , 'message' => " Mail send Successfully " ]);
} else {
return response () -> json ([ 'status' => 201 , 'message' => " Mail not send " ]);
}
}
public function viewReplyMail ( $id , $return , $table )
{
$replies = BuyerSentMail :: with ( 'users' ) -> where ( 'marketplace_buyer_forms_id' , '=' , $id ) -> get ();
$backRoute = $backRoute = route ( 'interest-buyers' , [ 'id' => $return , 'table' => $table ]);
return view ( 'Admin.Pages.pre_owned_investment.partial.mails-reply' , compact ( 'replies' , 'backRoute' ));
}
public function updateCompleteTransaction ( Request $request )
{
2024-05-08 17:46:59 +05:30
// dd($request->all());
2024-03-28 14:52:40 +05:30
$completedTransactionUpdated = MarketplaceBuyerForm :: where ( 'id' , $request -> buyer_id ) -> update ([
'complete_units_sold' => $request -> final_units_sold ,
'complete_sale_value' => $request -> final_sale_value ,
'commission_earned' => $request -> commission_earned ,
'date_of_sale' => $request -> date_of_sale ,
'platform' => $request -> platform ,
'final_purchase_value' => $request -> final_purchase_value ,
]);
if ( $completedTransactionUpdated ) {
return response () -> json ([ 'status' => 200 , 'message' => 'Transaction Updated!' ], 200 );
} else {
return response () -> json ([ " status " => 400 , 'message' => 'Transaction Cannot Be Updated!' ], 400 );
}
}
2024-07-04 13:34:21 +05:30
}