2024-03-28 14:52:40 +05:30
< ? php
namespace App\Http\Controllers\Frontend ;
use App\Http\Controllers\Controller ;
use App\Models\Admin\User ;
use App\Models\AlternativeInvestmentFund ;
use App\Models\Company ;
2024-05-15 16:53:32 +05:30
use App\Models\Product ;
2024-03-28 14:52:40 +05:30
use App\Models\UserKyc ;
use App\Models\FractionalRealEstate ;
use App\Models\Frontend\User as FrontendUser ;
use App\Models\MarketplaceAlternativeInvestmentFundSeller ;
use App\Models\MarketplaceBuyerForm ;
use App\Models\MarketplaceFractionalRealEstateSeller ;
use App\Models\MarketplaceOtherProductsSeller ;
use App\Models\MarketplaceSellerForm ;
use Illuminate\Http\Request ;
use App\Models\MonthlyUpdateMaster ;
use App\Models\MonthlyUpdateAlternativeInvestmentFund ;
use App\Models\MonthlyUpdateIndianFinancialAssets ;
use App\Models\MonthlyUpdatePeerToPeerLending ;
use App\Models\MonthlyUpdateFractionalRealEstate ;
use App\Models\User as ModelsUser ;
use App\Notifications\UserAdmin ;
use Illuminate\Support\Facades\Crypt ;
use Illuminate\Support\Facades\Validator ;
use Cviebrock\EloquentSluggable\Services\SlugService ;
2024-05-17 13:10:50 +05:30
use Illuminate\Support\Facades\Session ;
2024-03-28 14:52:40 +05:30
use DB ;
class DashboardController extends Controller
{
public function index ()
{
$user = $this -> getUser () -> data ;
$currentInvestmentProduct = $this -> view_investors_details ( 'Holding' );
2024-05-14 12:50:39 +05:30
// dd($currentInvestmentProduct);
2024-03-28 14:52:40 +05:30
$reedemedInvestmentProduct = $this -> view_investors_details ( 'Reedemed' );
2024-05-10 11:52:09 +05:30
// investment on watchlist
2024-03-28 14:52:40 +05:30
$aifInvestmentWatchlist = $this -> aifInvestmentWatchlist ()[ 'data' ];
$freInvestmentWatchlist = $this -> freInvestmentWatchlist ()[ 'data' ];
$opInvestmentWatchlist = $this -> opInvestmentWatchlist ()[ 'data' ];
2024-05-10 11:52:09 +05:30
// dd($freInvestmentWatchlist);
// investment on bought
2024-03-28 14:52:40 +05:30
$aifSoldInvestmentWatchlist = $this -> aifSoldInvestmentWatchlist ()[ 'data' ];
$freSoldInvestmentWatchlist = $this -> freSoldInvestmentWatchlist ()[ 'data' ];
$opSoldInvestmentWatchlist = $this -> opSoldInvestmentWatchlist ()[ 'data' ];
2024-05-10 11:52:09 +05:30
2024-04-19 15:16:12 +05:30
// bought
2024-03-28 14:52:40 +05:30
$aifInvestmentListed = $this -> aifInvestmentListed ()[ 'data' ];
$freInvestmentListed = $this -> freInvestmentListed ()[ 'data' ];
$opInvestmentListed = $this -> opInvestmentListed ()[ 'data' ];
2024-05-10 11:52:09 +05:30
// investment on sale
2024-04-29 19:19:42 +05:30
$marketPlaceAIFSellerData = $this -> getMarketplaceAIFSellerData ( 1 );
$marketPlaceFRESellerData = $this -> getMarketplaceFRESellerData ( 1 );
2024-05-10 11:52:09 +05:30
2024-05-02 15:22:44 +05:30
// dd($marketPlaceFRESellerData);
2024-03-28 14:52:40 +05:30
$marketPlaceOPSellerData = $this -> getMarketplaceOPSellerData ();
$totalInvestmentTillDate = '₹ ' . $this -> IND_money_format ( $currentInvestmentProduct [ 'totalInvestmentInInt' ] + $reedemedInvestmentProduct [ 'totalInvestmentInInt' ]);
return view ( 'Frontend.Pages.profile.dashboard' , compact ( 'currentInvestmentProduct' , 'reedemedInvestmentProduct' , 'totalInvestmentTillDate' , 'aifInvestmentWatchlist' , 'freInvestmentWatchlist' , 'opInvestmentWatchlist' , 'aifSoldInvestmentWatchlist' , 'freSoldInvestmentWatchlist' , 'opSoldInvestmentWatchlist' , 'user' , 'aifInvestmentListed' , 'freInvestmentListed' , 'opInvestmentListed' , 'marketPlaceAIFSellerData' , 'marketPlaceFRESellerData' , 'marketPlaceOPSellerData' ));
}
2024-04-29 19:19:42 +05:30
public function getMarketplaceAIFSellerData ( $api = null )
2024-03-28 14:52:40 +05:30
{
2024-04-29 17:15:31 +05:30
$id = auth () -> guard ( 'users' ) -> user () -> id ? ? request () -> user () -> id ;
2024-04-26 12:23:43 +05:30
// $market_place_data = MarketplaceBuyerForm::where(['users_id' => $id, 'status' => 'Sold', 'table' => 'marketplace_aif_sellers'])->get();
// foreach ($market_place_data as $row) {
// $row['marketplace_aif_sellers_data'] = MarketplaceAlternativeInvestmentFundSeller::where('id', $row->associated_id)->first();
// }
// return $market_place_data;
2024-04-26 18:40:07 +05:30
// $sellerData = MarketplaceSellerForm::has('aif')->with('aif')->where('users_id',$id)->get();
$sellerData = MarketplaceSellerForm :: with ( 'aif' ) -> where ( 'users_id' , $id ) -> get ();
// dd($sellerData);
2024-04-26 12:23:43 +05:30
// return $sellerData[0]->aif['name_of_the_aif_fund'];
2024-04-29 19:19:42 +05:30
// return $api;
if ( $api == null )
{
$data [ 'data' ] = $sellerData ;
return $data ;
}
2024-04-26 12:23:43 +05:30
if ( count ( $sellerData -> toArray ()))
{
$market_place_data = $sellerData [ 0 ] -> aif -> toArray ();
2024-04-29 19:19:42 +05:30
// dd($market_place_data);
2024-04-26 12:23:43 +05:30
return $market_place_data ;
2024-03-28 14:52:40 +05:30
}
2024-04-26 12:23:43 +05:30
return $sellerData ;
2024-03-28 14:52:40 +05:30
}
public function aifSoldInvestment ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_aif_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_aif_sellers.id' )
-> alernativeInvestmentFund ()
-> sold ()
2024-04-29 17:15:31 +05:30
-> where ( 'listing_status' , '!=' , 'Hide' )
2024-03-28 14:52:40 +05:30
-> select ( 'name_of_the_aif_fund' , 'fund_category' , 'fund_strategy' , 'type_of_fund' , 'total_capital_commitment' , 'uncalled_capital_commitment' )
-> get ();
return $data ;
}
public function freSoldInvestment ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_fre_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_fre_sellers.id' )
-> fractionalRealEstate ()
-> sold ()
// ->where('listing_status', '!=', 'Hide')
-> select ( 'property_name' , 'property_address' , 'property_grade' , 'asset_type' , 'fractional_real_estate_platform' , 'expected_selling_price' )
-> get ();
return $data ;
}
public function opSoldInvestment ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_op_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_op_sellers.id' )
-> otherProducts ()
-> sold ()
// ->where('listing_status', '!=', 'Hide')
-> select ( 'security_name' , 'product_category' , 'instrument_type' , 'instrument_issuer' , 'credit_rating' , 'expected_sale_price_per_unit' )
-> get ();
return $data ;
}
2024-04-29 19:19:42 +05:30
public function getMarketplaceFRESellerData ( $api = null )
2024-03-28 14:52:40 +05:30
{
2024-04-29 17:15:31 +05:30
$id = auth () -> guard ( 'users' ) -> user () -> id ? ? request () -> user () -> id ;
2024-04-26 12:23:43 +05:30
// $market_place_data = MarketplaceBuyerForm::where(['users_id' => $id, 'status' => 'Sold', 'table' => 'marketplace_fre_sellers'])->get();
// foreach ($market_place_data as $row) {
// $row['marketplace_fre_sellers_data'] = MarketplaceFractionalRealEstateSeller::where('id', $row->associated_id)->first();
// }
// return $market_place_data;
2024-04-26 18:40:07 +05:30
$sellerData = MarketplaceSellerForm :: with ( 'fre' ) -> where ( 'users_id' , $id ) -> get ();
2024-05-10 11:52:09 +05:30
// dd($sellerData);
$sellerData -> each ( function ( $value ){
$value -> fre -> each ( function ( $fre ){
// dd($fre);
if ( $fre )
{
$fre [ 'company_name' ] = Company :: where ( 'id' , $fre -> fractional_real_estate_platform ) -> value ( 'company_name' );
}
});
// dd($value->fre[0]->fractional_real_estate_platform);
});
// dd($sellerData->toArray());
2024-04-29 19:19:42 +05:30
if ( $api == null )
{
$data [ 'data' ] = $sellerData ;
return $data ;
}
2024-04-26 12:23:43 +05:30
if ( count ( $sellerData -> toArray ()))
{
$market_place_data = $sellerData [ 0 ] -> fre -> toArray ();
return $market_place_data ;
2024-03-28 14:52:40 +05:30
}
2024-04-26 12:23:43 +05:30
return $sellerData ;
// if($sellerData->toArray()->count())
2024-03-28 14:52:40 +05:30
}
public function getMarketplaceOPSellerData ()
{
$id = auth () -> guard ( 'users' ) -> user () -> id ;
$market_place_data = MarketplaceBuyerForm :: where ([ 'users_id' => $id , 'status' => 'Sold' , 'table' => 'marketplace_op_sellers' ]) -> get ();
foreach ( $market_place_data as $row ) {
$row [ 'marketplace_op_sellers_data' ] = MarketplaceOtherProductsSeller :: where ( 'id' , $row -> associated_id ) -> first ();
}
return $market_place_data ;
}
public function getUser ()
{
$data = User :: where ( 'id' , auth () -> guard ( 'users' ) -> user () -> id ? ? request () -> user () -> id ) -> first ();
return ( object )[
'data' => ( object )[
'name' => $data -> name ,
'contact_no' => $data -> contact_number ,
'email' => $data -> email ,
'address' => $data -> address
]
];
}
public function viewInvestmentDetails ()
{
$currentInvestmentProduct = $this -> view_investors_details ( 'Holding' );
$reedemedInvestmentProduct = $this -> view_investors_details ( 'Reedemed' );
$totalInvestmentTillDate = '₹ ' . $this -> IND_money_format ( $currentInvestmentProduct [ 'totalInvestmentInInt' ] + $reedemedInvestmentProduct [ 'totalInvestmentInInt' ]);
return [
'currentInvestmentProduct' => $currentInvestmentProduct ,
'reedemedInvestmentProduct' => $reedemedInvestmentProduct ,
'totalInvestmentTillDate' => $totalInvestmentTillDate ,
];
}
public function investmentSummary ()
{
$currentInvestmentProduct = $this -> view_investors_details_api ( 'Holding' );
$reedemedInvestmentProduct = $this -> view_investors_details_api ( 'Reedemed' );
$totalInvestmentTillDate = '₹ ' . $this -> IND_money_format ( $currentInvestmentProduct [ 'totalInvestmentInInt' ] + $reedemedInvestmentProduct [ 'totalInvestmentInInt' ]);
$result [ 'totalInvestmentTillDate' ] = $totalInvestmentTillDate ;
$result [ 'activeInvestment' ] = $currentInvestmentProduct [ 'totalInvestment' ];
$result [ 'reedemedInvestment' ] = $reedemedInvestmentProduct [ 'totalInvestment' ];
$data [ 'data' ] = $result ;
return $data ;
}
public function currentInvestmentDetails ()
{
$currentInvestmentProduct = $this -> view_investors_details_api ( 'Holding' );
$result [ 'currentInvestment' ] = $currentInvestmentProduct ;
$data [ 'data' ] = $result ;
return $data ;
}
public function reedemedInvestmentDetails ()
{
$currentInvestmentProduct = $this -> view_investors_details_api ( 'Reedemed' );
$result [ 'reedemedInvestment' ] = $currentInvestmentProduct ;
$data [ 'data' ] = $result ;
return $data ;
}
public function view_investors_details_api ( $holdingStatus )
{
$id = request () -> user () -> id ;
$user = MonthlyUpdateMaster :: where ([ 'users_id' => $id , 'holding_status' => $holdingStatus , 'status' => true ]) -> get ();
// $user = MonthlyUpdateMaster::whereUsersIDAndHoldingStatus($id,$holdingStatus)->get();
$productDetails = [];
foreach ( $user as $singleMUM ) {
if ( MonthlyUpdateAlternativeInvestmentFund :: where ( 'custom_id' , $singleMUM -> custom_id ) -> exists ()) {
$data = MonthlyUpdateAlternativeInvestmentFund :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
$investmentArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'commitment_amount' ));
array_push ( $productDetails , $investmentArr );
} elseif ( MonthlyUpdateFractionalRealEstate :: where ( 'custom_id' , $singleMUM -> custom_id ) -> first ()) {
$data = MonthlyUpdateFractionalRealEstate :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
2024-05-17 11:42:58 +05:30
// dd($data);
$investmentArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'investment_value' ));
2024-03-28 14:52:40 +05:30
array_push ( $productDetails , $investmentArr );
} elseif ( MonthlyUpdatePeerToPeerLending :: where ( 'custom_id' , $singleMUM -> custom_id ) -> first ()) {
$data = MonthlyUpdatePeerToPeerLending :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
if ( $singleMUM -> categories == 'Liquiloans' ) {
$investmentArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'total_investment' ));
} elseif ( $singleMUM -> categories == 'Faircent' ) {
$investmentArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'all_time_amount_invested' ));
} elseif ( $singleMUM -> categories == 'Finance Peer' ) {
$investmentArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'all_time_investment_added' ));
}
array_push ( $productDetails , $investmentArr );
} elseif ( MonthlyUpdateIndianFinancialAssets :: where ( 'custom_id' , $singleMUM -> custom_id ) -> first ()) {
$data = MonthlyUpdateIndianFinancialAssets :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
$dataArr = $this -> totalInvestmentAmount_api ( $singleMUM , $data -> getRawOriginal ( 'amount_invested' ));
array_push ( $productDetails , $dataArr );
}
}
$totalInvestmentInInt = array_sum ( array_column ( $productDetails , 'total_investment_amount' ));
$totalInvestment = '₹ ' . $this -> IND_money_format (( $totalInvestmentInInt ));
return [
'totalInvestment' => $totalInvestment ,
'productDetails' => $productDetails ,
'totalInvestmentInInt' => sprintf ( " %.2f " , $totalInvestmentInInt )
];
// $user = User::findOrFail($id);
// return view('Admin.Pages.manage_investors.view_investors_detail', compact('user', 'productDetails', 'totalInvestment'));
}
public function view_investors_details ( $holdingStatus )
{
$id = auth () -> guard ( 'users' ) -> user () -> id ? ? request () -> user () -> id ;
$user = MonthlyUpdateMaster :: where ([ 'users_id' => $id , 'holding_status' => $holdingStatus , 'status' => true ])
-> whereIn ( 'categories' , [ 'Alternative Investment Fund' , 'Fractional Real Estate' ])
-> get ();
// $user = MonthlyUpdateMaster::whereUsersIDAndHoldingStatus($id,$holdingStatus)->get();
// dd($holdingStatus);
$productDetails = [];
foreach ( $user as $singleMUM ) {
if ( MonthlyUpdateAlternativeInvestmentFund :: where ( 'custom_id' , $singleMUM -> custom_id ) -> exists ()) {
$data = MonthlyUpdateAlternativeInvestmentFund :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
$investmentArr = $this -> totalInvestmentAmount ( $singleMUM , $data -> getRawOriginal ( 'commitment_amount' ));
array_push ( $productDetails , $investmentArr );
} elseif ( MonthlyUpdateFractionalRealEstate :: where ( 'custom_id' , $singleMUM -> custom_id ) -> first ()) {
$data = MonthlyUpdateFractionalRealEstate :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
2024-05-17 11:42:58 +05:30
// dd($data);
$investmentArr = $this -> totalInvestmentAmount ( $singleMUM , $data -> getRawOriginal ( 'investment_value' ));
2024-03-28 14:52:40 +05:30
array_push ( $productDetails , $investmentArr );
}
// elseif (MonthlyUpdatePeerToPeerLending::where('custom_id', $singleMUM->custom_id)->first()) {
// $data = MonthlyUpdatePeerToPeerLending::where('custom_id', $singleMUM->custom_id)->latest()->first();
// // dd($data);
// if ($singleMUM->categories == 'Liquiloans') {
// // dd($singleMUM);
// $investmentArr = $this->totalInvestmentAmount($singleMUM, $data->getRawOriginal('total_investment'));
// } elseif ($singleMUM->categories == 'Faircent') {
// $investmentArr = $this->totalInvestmentAmount($singleMUM, $data->getRawOriginal('all_time_amount_invested'));
// } elseif ($singleMUM->categories == 'Finance Peer') {
// $investmentArr = $this->totalInvestmentAmount($singleMUM, $data->getRawOriginal('all_time_investment_added'));
// }
// array_push($productDetails, $investmentArr);
// }
elseif ( MonthlyUpdateIndianFinancialAssets :: where ( 'custom_id' , $singleMUM -> custom_id ) -> first ()) {
$data = MonthlyUpdateIndianFinancialAssets :: where ( 'custom_id' , $singleMUM -> custom_id ) -> latest () -> first ();
$dataArr = $this -> totalInvestmentAmount ( $singleMUM , $data -> getRawOriginal ( 'amount_invested' ));
array_push ( $productDetails , $dataArr );
}
}
$totalInvestmentInInt = array_sum ( array_column ( $productDetails , 'total_investment_amount' ));
// dd($totalInvestmentInInt);
$totalInvestment = '₹ ' . $this -> IND_money_format (( $totalInvestmentInInt ));
return [
'totalInvestment' => $totalInvestment ,
'productDetails' => $productDetails ,
'totalInvestmentInInt' => $totalInvestmentInInt
];
// $user = User::findOrFail($id);
// return view('Admin.Pages.manage_investors.view_investors_detail', compact('user', 'productDetails', 'totalInvestment'));
}
function IND_money_format ( $number )
{
$decimal = ( string )( $number - floor ( $number ));
$money = floor ( $number );
$length = strlen ( $money );
$delimiter = '' ;
$money = strrev ( $money );
for ( $i = 0 ; $i < $length ; $i ++ ) {
if (( $i == 3 || ( $i > 3 && ( $i - 1 ) % 2 == 0 )) && $i != $length ) {
$delimiter .= ',' ;
}
$delimiter .= $money [ $i ];
}
$result = strrev ( $delimiter );
$decimal = preg_replace ( " /0 \ ./i " , " . " , $decimal );
$decimal = substr ( $decimal , 0 , 3 );
if ( $decimal != '0' ) {
$result = $result . $decimal ;
}
return $result ;
}
function totalInvestmentAmount ( $singleMUM , $amount )
{
// dd($singleMUM);
$p2p = [ 'Faircent' , 'Finance Peer' , 'Liquiloans' ];
if ( in_array ( $singleMUM -> categories , $p2p )) {
$categories = 'Peer To Peer Lending' ;
} else {
$categories = $singleMUM -> categories ;
}
$dataArr = [
'id' => $singleMUM -> id ,
2024-05-14 12:50:39 +05:30
'company_logo' => Company :: where ( 'id' , $singleMUM -> investment_platform ) -> value ( 'company_logo' ),
2024-03-28 14:52:40 +05:30
'custom_id' => $singleMUM -> custom_id ,
'categories' => $categories ,
'product_category' => $singleMUM -> product_category ,
'product_name' => $singleMUM -> product_name ,
'date_of_investment' => $singleMUM -> created_at -> format ( 'd/m/y' ),
2024-05-14 12:50:39 +05:30
'company_name' => Company :: where ( 'id' , $singleMUM -> investment_platform ) -> value ( 'company_name' ),
2024-03-28 14:52:40 +05:30
'route_id' => \Crypt :: encrypt ( $singleMUM -> custom_id )
];
$dataArr [ 'total_investment_amount' ] = $amount ;
$dataArr [ 'total_investment_amount_display' ] = '₹ ' . $this -> IND_money_format ( $amount );
return $dataArr ;
}
2024-05-15 16:53:32 +05:30
public function getProductDetail ( Request $request )
{
$id = $request -> id ;
2024-05-17 16:47:12 +05:30
// dd($id);
2024-05-15 16:53:32 +05:30
if ( $id )
{
$product_id = MonthlyUpdateMaster :: where ( 'id' , $id ) -> value ( 'products_id' );
2024-05-17 16:47:12 +05:30
// dd(FractionalRealEstate::where('products_id',$product_id)->exists());
2024-05-15 16:53:32 +05:30
if ( AlternativeInvestmentFund :: where ( 'products_id' , $product_id ) -> exists ())
{
$data = Product :: with ( 'alternativeInvestmentFund' , 'categorys' ) -> where ( 'id' , $product_id ) -> first ();
return response () -> json ([ 'status' => 200 , 'data' => $data ]);
}
if ( FractionalRealEstate :: where ( 'products_id' , $product_id ) -> exists ())
{
$data = Product :: with ( 'fractional_real_estate' , 'categorys' ) -> where ( 'id' , $product_id ) -> first ();
return response () -> json ([ 'status' => 200 , 'data' => $data ]);
}
}
return response () -> json ([ 'status' => 404 , 'message' => 'id is null' ]);
}
2024-03-28 14:52:40 +05:30
function totalInvestmentAmount_api ( $singleMUM , $amount )
{
$p2p = [ 'Faircent' , 'Finance Peer' , 'Liquiloans' ];
if ( in_array ( $singleMUM -> categories , $p2p )) {
$categories = 'Peer To Peer Lending' ;
} else {
$categories = $singleMUM -> categories ;
}
$dataArr = [
// 'id' => $singleMUM->id,
2024-05-14 12:50:39 +05:30
'company_logo' => Company :: where ( 'id' , $singleMUM -> investment_platform ) -> value ( 'company_logo' ),
2024-03-28 14:52:40 +05:30
'custom_id' => $singleMUM -> custom_id ,
'categories' => $singleMUM -> categories ,
// 'product_category' => $singleMUM->product_category,
'product_name' => $singleMUM -> product_name ,
// 'date_of_investment' => $singleMUM->created_at->format('d/m/y'),
// 'company_name' => Company::find($singleMUM->investment_platform)->value('company_name'),
'route_id' => \Crypt :: encrypt ( $singleMUM -> custom_id )
];
$dataArr [ 'total_investment_amount' ] = $amount ;
$dataArr [ 'amount' ] = '₹ ' . $this -> IND_money_format ( $amount );
return $dataArr ;
}
public function investmentDetails ( $customId )
{
// $customId = Crypt::decrypt($customId);
$data = $this -> getInvestmentDetails ( $customId );
2024-05-14 12:50:39 +05:30
// dd($data);
2024-03-28 14:52:40 +05:30
return view ( 'Frontend.Pages.profile.investment-details.index' , compact ( 'data' ));
}
public function getInvestmentDetails ( $customId )
{
$data = array ();
$customId = Crypt :: decrypt ( $customId );
$monthlyUpdateMaster = MonthlyUpdateMaster :: where ( 'custom_id' , $customId ) -> firstOrFail ();
2024-05-14 12:50:39 +05:30
// dd($monthlyUpdateMaster);
2024-03-28 14:52:40 +05:30
$data [ 'basic-details' ] = $monthlyUpdateMaster ;
2024-05-14 12:50:39 +05:30
$data [ 'company_name' ] = Company :: where ( 'id' , $monthlyUpdateMaster -> investment_platform ) -> value ( 'company_name' );
$data [ 'company_logo' ] = Company :: where ( 'id' , $monthlyUpdateMaster -> investment_platform ) -> value ( 'company_logo' );
2024-03-28 14:52:40 +05:30
if ( MonthlyUpdateAlternativeInvestmentFund :: where ( 'custom_id' , $customId ) -> exists ()) {
$data [ 'category' ] = 'Alternative Investment Fund' ;
$data [ 'data' ] = MonthlyUpdateAlternativeInvestmentFund :: where ([ 'custom_id' => $customId , 'status' => true ]) -> latest () -> first ();
} elseif ( MonthlyUpdateFractionalRealEstate :: where ( 'custom_id' , $customId ) -> exists ()) {
$data [ 'category' ] = 'Fractional Real Estate' ;
$data [ 'data' ] = MonthlyUpdateFractionalRealEstate :: where ([ 'custom_id' => $customId , 'status' => true ]) -> latest () -> first ();
} elseif ( MonthlyUpdatePeerToPeerLending :: where ( 'custom_id' , $customId ) -> exists ()) {
$data [ 'category' ] = 'Peer To Peer Lending' ;
$data [ 'data' ] = MonthlyUpdatePeerToPeerLending :: where ([ 'custom_id' => $customId , 'status' => true ]) -> latest () -> first ();
} elseif ( MonthlyUpdateIndianFinancialAssets :: where ( 'custom_id' , $customId ) -> exists ()) {
$data [ 'category' ] = 'Indian Financial Assets' ;
$data [ 'data' ] = MonthlyUpdateIndianFinancialAssets :: where ([ 'custom_id' => $customId , 'status' => true ]) -> latest () -> first ();
} else {
abort ( 404 );
}
return $data ;
}
public function getStatementReportAPI ( $file_name )
{
return \Storage :: download ( 'files/monthly-update/' . $file_name );
}
public function viewDetailMarketPlace ( Request $request , $custom_id = null )
{
$activeSeller = MarketplaceSellerForm :: where ([ 'users_id' => auth () -> guard ( 'users' ) -> user () -> id , 'status' => 0 ]) -> exists ();
if ( $activeSeller ) {
abort ( 404 );
}
2024-05-17 13:10:50 +05:30
$products_id = null ;
2024-03-28 14:52:40 +05:30
if ( $custom_id ) {
$id = \Crypt :: decrypt ( $custom_id );
$data = MonthlyUpdateMaster :: with ( 'investor' ) -> where ( 'custom_id' , '=' , $id ) -> first ();
$category = $data -> categories ;
2024-05-17 11:33:18 +05:30
$products_id = $data -> products_id ;
2024-03-28 14:52:40 +05:30
if ( $category == " Fractional Real Estate " ) {
$data [ 'category' ] = 'Fractional Real Estate' ;
} elseif ( $category == " Alternative Investment Fund " ) {
$data [ 'category' ] = 'Alternative Investment Fund' ;
} else {
$data [ 'category' ] = 'Other Products' ;
}
} else {
$data = '' ;
}
2024-05-15 16:20:28 +05:30
$userKyc = UserKyc :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> exists ();
2024-03-28 14:52:40 +05:30
$userData = array ();
2024-05-15 16:20:28 +05:30
// $user;
2024-05-15 17:15:48 +05:30
$user = ModelsUser :: where ( 'id' , auth () -> guard ( 'users' ) -> user () -> id ) -> first ();
$marketPlaceSellerForm = MarketplaceSellerForm :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> first ();
// if ($userKyc) {
2024-05-15 16:20:28 +05:30
// dd($marketPlaceSellerForm);
2024-05-15 17:15:48 +05:30
// }
2024-05-15 17:12:08 +05:30
$userData = ( object )[
'encrypted_custom_id' => $custom_id ,
'name' => $user -> name ? ? $user -> name ,
'city' => $marketPlaceSellerForm -> city ? ? null ,
'country' => $marketPlaceSellerForm -> country ? ? null ,
'postal_code' => $marketPlaceSellerForm -> postal_code ? ? null ,
'contact_number' => $user -> contact_number ? ? $user -> contact_number ,
'email' => $user -> email ? ? $user -> email ,
'declaration' => $user -> declaration ? ? null ,
];
2024-05-15 16:20:28 +05:30
// $userData = (object)[
// 'encrypted_custom_id' => $custom_id,
// 'name' => $userKyc ? $marketPlaceSellerForm->name ?? $user->name : null,
// 'city' => $userKyc ? $marketPlaceSellerForm->city ?? null : null,
// 'country' => $userKyc ? $marketPlaceSellerForm->country ?? null : null,
// 'postal_code' => $userKyc ? $marketPlaceSellerForm->postal_code ?? null : null,
// 'contact_number' => $userKyc ? $marketPlaceSellerForm->contact_number ?? $user->contact_number : null,
// 'email' => $userKyc ? $marketPlaceSellerForm->email ?? $user->email : null,
// 'declaration' => $userKyc ? $marketPlaceSellerForm->declaration ?? null : null,
// ];
2024-05-17 11:15:52 +05:30
return view ( 'Frontend.Pages.profile.market-list.sale-form' , compact ( 'data' , 'userData' , 'products_id' ));
2024-03-28 14:52:40 +05:30
}
public function sellerFormSubmit ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'name' => 'required' ,
'city' => 'required' ,
'country' => 'required' ,
'postal_code' => 'required' ,
'contact_number' => 'required|digits:10' ,
'email' => 'required' ,
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 13:10:50 +05:30
// $sellerFormUpdateCreate = MarketplaceSellerForm::updateOrCreate([
// 'users_id' => auth()->guard('users')->user()->id
// ],
$data = [
2024-03-28 14:52:40 +05:30
'name' => $request -> name ,
'city' => $request -> city ,
'country' => $request -> country ,
'postal_code' => $request -> postal_code ,
'contact_number' => $request -> contact_number ,
'email' => $request -> email ,
2024-05-17 13:10:50 +05:30
];
session :: put ( 'sellerFormData' , $data );
if ( session :: has ( 'sellerFormData' )) {
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Seller Form Reviewed & Submitted!' ]);
}
return response () -> json ([ 'status' => 400 , 'message' => 'Seller Form Could Not Be Reviewed & Submitted!' ]);
}
public function alternativeInvestmentFundSellerForm ( $custom_id = null )
{
2024-05-21 17:01:11 +05:30
// if (MarketplaceSellerForm::where('users_id', auth()->guard('users')->user()->id)->where('status', true)->doesntExist()) {
// abort(403);
// }
2024-03-28 14:52:40 +05:30
if ( $custom_id ) {
$productId = MonthlyUpdateMaster :: where ([ 'custom_id' => \Crypt :: decrypt ( $custom_id ), 'users_id' => auth () -> guard ( 'users' ) -> user () -> id ]) -> value ( 'products_id' );
$alternativeInvestmentFund = AlternativeInvestmentFund :: where ( 'products_id' , $productId ) -> first ();
2024-05-17 17:17:11 +05:30
// dd($alternativeInvestmentFund);
2024-03-28 14:52:40 +05:30
$monthlyUpdateMaster = MonthlyUpdateMaster :: where ([ 'custom_id' => \Crypt :: decrypt ( $custom_id ), 'users_id' => auth () -> guard ( 'users' ) -> user () -> id ]) -> first ();
2024-05-17 13:10:50 +05:30
// dd($alternativeInvestmentFund);
2024-03-28 14:52:40 +05:30
}
2024-05-17 17:17:11 +05:30
$aifProduct = ( object )[
2024-03-28 14:52:40 +05:30
// 'encrypted_custom_id' => $custom_id,
'name_of_the_aif_fund' => $monthlyUpdateMaster -> product_name ? ? null ,
'fund_category' => $monthlyUpdateMaster -> fund_category ? ? null ,
'fund_structure' => $alternativeInvestmentFund -> fund_structure ? ? null ,
'type_of_fund' => null ,
'fund_strategy' => $alternativeInvestmentFund -> fund_strategy ? ? null ,
'fund_manager_name' => $alternativeInvestmentFund -> fund_manager_name ? ? null ,
'sponsor' => $alternativeInvestmentFund -> sponsor ? ? null ,
'credit_rating' => $alternativeInvestmentFund -> credit_rating ? ? null ,
'total_capital_commitment' => $monthlyUpdateMaster -> contribution_called_amount ? ? null ,
'uncalled_capital_commitment' => $monthlyUpdateMaster -> contribution_uncalled_amount ? ? null ,
'date_of_final_close' => $alternativeInvestmentFund -> final_close_date ? ? null ,
'tenure_from_final_close' => $alternativeInvestmentFund -> tenure_from_final_date ? ? null ,
'current_or_latest_nav' => $monthlyUpdateMaster -> current_nav ? ? null ,
'no_of_units_held' => $monthlyUpdateMaster -> no_of_units_held ? ? null ,
];
// dd($aifProduct);
return view ( 'Frontend.Pages.profile.market-list.alternative-investment-fund' , compact ( 'aifProduct' ));
}
public function fractionalRealEstateSellerForm ( $custom_id = null )
{
2024-05-21 17:01:11 +05:30
// if (MarketplaceSellerForm::where('users_id', auth()->guard('users')->user()->id)->where('status', true)->doesntExist()) {
// abort(403);
// }
2024-03-28 14:52:40 +05:30
if ( $custom_id ) {
$productId = MonthlyUpdateMaster :: where ([ 'custom_id' => \Crypt :: decrypt ( $custom_id ), 'users_id' => auth () -> guard ( 'users' ) -> user () -> id ]) -> value ( 'products_id' );
$fractionalRealEstate = FractionalRealEstate :: where ( 'products_id' , $productId ) -> first ();
$monthlyUpdateMaster = MonthlyUpdateMaster :: where ([ 'custom_id' => \Crypt :: decrypt ( $custom_id ), 'users_id' => auth () -> guard ( 'users' ) -> user () -> id ]) -> first ();
$monthlyUpdateFRE = MonthlyUpdateFractionalRealEstate :: where ([ 'custom_id' => \Crypt :: decrypt ( $custom_id )]) -> first ();
$fractionalRealEstatePlatform = Company :: find ( $monthlyUpdateMaster -> investment_platform ) -> value ( 'company_name' ) ? ? null ;
}
$freProduct = ( object )[
// 'encrypted_custom_id' => $custom_id,
'property_name' => $monthlyUpdateMaster -> product_name ? ? null ,
'property_address' => null ,
'property_grade' => $fractionalRealEstate -> property_grade ? ? null ,
'asset_type' => null ,
'annual_rental_yield_earned' => null ,
'rental_escalation' => $fractionalRealEstate -> rental_escalation ? ? null ,
'fractional_real_estate_platform' => $fractionalRealEstatePlatform ? ? null ,
'date_of_investment' => $monthlyUpdateFRE -> investment_date ? ? null ,
'original_amount_invested' => $monthlyUpdateFRE -> investment_value ? ? null ,
'current_market_value_of_the_property' => $monthlyUpdateFRE -> total_value_of_the_property ? ? null ,
'expected_selling_price' => null ,
];
$companies = Company :: active () -> get ([ 'id' , 'company_name' ]);
return view ( 'Frontend.Pages.profile.market-list.fractional-real-estate' , compact ( 'freProduct' , 'companies' ));
}
public function otherProductsSellerForm ( $custom_id = null )
{
if ( MarketplaceSellerForm :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> where ( 'status' , true ) -> doesntExist ()) {
abort ( 403 );
}
return view ( 'Frontend.Pages.profile.market-list.other-investment' );
}
public function marketplaceAIFForm ( Request $request )
{
2024-05-15 14:39:18 +05:30
// dd($request->all());
2024-03-28 14:52:40 +05:30
$validator = Validator :: make ( $request -> all (), [
'name_of_the_aif_fund' => 'required' ,
'fund_category' => 'required' ,
'fund_structure' => 'required' ,
'type_of_fund' => 'required' ,
2024-05-16 15:40:08 +05:30
// 'fund_strategy' => 'required',
// 'fund_manager_name' => 'required',
// 'sponsor' => 'required',
2024-03-28 14:52:40 +05:30
// 'credit_rating' => 'required',
'total_capital_commitment' => 'required' ,
'uncalled_capital_commitment' => 'required' ,
2024-05-16 15:40:08 +05:30
// 'date_of_final_close' => 'required',
// 'tenure_from_final_close' => 'required',
2024-03-28 14:52:40 +05:30
'current_or_latest_nav' => 'required' ,
'no_of_units_held' => 'required' ,
2024-05-16 15:40:08 +05:30
// 'no_of_units_you_wish_to_sell' => 'required',
2024-03-28 14:52:40 +05:30
'expected_sale_per_unit' => 'required' ,
2024-04-08 13:45:25 +05:30
'latest_valuation_date' => 'required' ,
2024-03-28 14:52:40 +05:30
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 13:10:50 +05:30
// dd(session::get('sellerFormData'));
$sellerFormUpdateCreate = MarketplaceSellerForm :: updateOrCreate ([
'users_id' => auth () -> guard ( 'users' ) -> user () -> id
2024-05-29 16:29:37 +05:30
], session :: get ( 'sellerFormData' ));
2024-05-17 13:10:50 +05:30
// dd($sellerFormUpdateCreate);
2024-03-28 14:52:40 +05:30
$aifSellerForm = MarketplaceAlternativeInvestmentFundSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> value ( 'id' ),
'name_of_the_aif_fund' => $request -> name_of_the_aif_fund ,
'slug' => SlugService :: createSlug ( MarketplaceAlternativeInvestmentFundSeller :: class , 'slug' , $request -> name_of_the_aif_fund ),
'fund_category' => $request -> fund_category ,
'fund_structure' => $request -> fund_structure ,
'type_of_fund' => $request -> type_of_fund ,
2024-05-16 15:40:08 +05:30
'fund_strategy' => $request -> fund_strategy ? ? null ,
'fund_manager_name' => $request -> fund_manager_name ? ? null ,
'sponsor' => $request -> sponsor ? ? null ,
'credit_rating' => $request -> credit_rating ? ? null ,
2024-03-28 14:52:40 +05:30
'total_capital_commitment' => $request -> total_capital_commitment ,
'uncalled_capital_commitment' => $request -> uncalled_capital_commitment ,
2024-05-16 15:40:08 +05:30
'date_of_final_close' => $request -> date_of_final_close ? ? null ,
'tenure_from_final_close' => $request -> tenure_from_final_close ? ? null ,
2024-03-28 14:52:40 +05:30
'current_or_latest_nav' => $request -> current_or_latest_nav ,
'no_of_units_held' => $request -> no_of_units_held ,
2024-05-16 15:40:08 +05:30
'no_of_units_you_wish_to_sell' => $request -> no_of_units_you_wish_to_sell ? ? null ,
'og_no_of_units_wish_to_sell' => $request -> no_of_units_you_wish_to_sell ? ? null ,
2024-03-28 14:52:40 +05:30
'expected_sale_per_unit' => $request -> expected_sale_per_unit ,
2024-04-08 13:45:25 +05:30
'latest_valuation_date' => $request -> latest_valuation_date ,
2024-03-28 14:52:40 +05:30
'listing_status' => 'Hide' ,
'status' => 'Pending'
]);
if ( $aifSellerForm ) {
$user = User :: find ( auth () -> guard ( 'users' ) -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Alternative Investment Fund' );
2024-05-29 16:29:37 +05:30
session :: forget ( 'sellerFormData' );
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Alternative Investment Fund Form Submitted For Review' ]);
}
return response () -> json ([ 'status' => 400 , 'message' => 'Alternative Investment Fund Form Could Not Be Submitted!' ]);
}
public function marketplaceFREForm ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'property_name' => 'required' ,
'property_address' => 'required' ,
'asset_type' => 'required' ,
'annual_rental_yield_earned' => 'required' ,
'fractional_real_estate_platform' => 'required' ,
'date_of_investment' => 'required' ,
'original_amount_invested' => 'required' ,
'current_market_value_of_the_property' => 'required' ,
'expected_selling_price' => 'required' ,
2024-04-08 13:45:25 +05:30
'latest_valuation_date' => 'required' ,
2024-03-28 14:52:40 +05:30
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 15:39:11 +05:30
$sellerFormUpdateCreate = MarketplaceSellerForm :: updateOrCreate ([
'users_id' => auth () -> guard ( 'users' ) -> user () -> id
2024-05-29 16:29:37 +05:30
], session :: get ( 'sellerFormData' ));
2024-03-28 14:52:40 +05:30
$freSellerForm = MarketplaceFractionalRealEstateSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> value ( 'id' ),
'property_name' => $request -> property_name ,
'slug' => SlugService :: createSlug ( MarketplaceFractionalRealEstateSeller :: class , 'slug' , $request -> property_name ),
'property_address' => $request -> property_address ,
'property_grade' => $request -> property_grade ,
'asset_type' => $request -> asset_type ,
'annual_rental_yield_earned' => $request -> annual_rental_yield_earned ,
'rental_escalation' => $request -> rental_escalation ,
'fractional_real_estate_platform' => $request -> fractional_real_estate_platform ,
'date_of_investment' => $request -> date_of_investment ,
'original_amount_invested' => $request -> original_amount_invested ,
'current_market_value_of_the_property' => $request -> current_market_value_of_the_property ,
'expected_selling_price' => $request -> expected_selling_price ,
2024-05-13 14:00:37 +05:30
'og_current_market_value_of_the_property' => $request -> current_market_value_of_the_property ,
'og_expected_selling_price' => $request -> expected_selling_price ,
2024-04-08 13:45:25 +05:30
'latest_valuation_date' => $request -> latest_valuation_date ,
2024-03-28 14:52:40 +05:30
'listing_status' => 'Hide' ,
'status' => 'Pending'
]);
if ( $freSellerForm ) {
$user = User :: find ( auth () -> guard ( 'users' ) -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Fractional Real Estate' );
2024-05-29 16:29:37 +05:30
session :: forget ( 'sellerFormData' );
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Fractional Real Estate Form Submitted For Review' ]);
}
return response () -> json ([ 'status' => 400 , 'message' => 'Fractional Real Estate Form Could Not Be Submitted!' ]);
}
public function marketplaceOPForm ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'product_category' => 'required' ,
'security_name' => 'required' ,
'instrument_type' => 'required' ,
'instrument_issuer' => 'required' ,
'isin' => 'required' ,
'credit_rating' => 'required' ,
'listed' => 'required' ,
'date_of_original_investment' => 'required' ,
'amount_invested' => 'required' ,
'no_of_units_held' => 'required' ,
'payout_frequency' => 'required' ,
'face_value_per_unit' => 'required' ,
'coupon_rate_in_pct' => 'required' ,
'maturity_date' => 'required' ,
'no_of_units_offered_for_sale' => 'required' ,
'expected_sale_price_per_unit' => 'required' ,
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
$opSellerForm = MarketplaceOtherProductsSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , auth () -> guard ( 'users' ) -> user () -> id ) -> value ( 'id' ),
'product_category' => $request -> product_category ,
'security_name' => $request -> security_name ,
'slug' => SlugService :: createSlug ( MarketplaceOtherProductsSeller :: class , 'slug' , $request -> security_name ),
'instrument_type' => $request -> instrument_type ,
'instrument_issuer' => $request -> instrument_issuer ,
'isin' => $request -> isin ,
'date_of_original_investment' => $request -> date_of_original_investment ,
'listed' => $request -> listed ,
'credit_rating' => $request -> credit_rating ,
'amount_invested' => $request -> amount_invested ,
'principal_repaid' => $request -> principal_repaid ,
'payout_frequency' => $request -> payout_frequency ,
'face_value_per_unit' => $request -> face_value_per_unit ,
'coupon_rate_in_pct' => $request -> coupon_rate_in_pct ,
'no_of_units_held' => $request -> no_of_units_held ,
'maturity_date' => $request -> maturity_date ,
'no_of_units_offered_for_sale' => $request -> no_of_units_offered_for_sale ,
'expected_sale_price_per_unit' => $request -> expected_sale_price_per_unit ,
'listing_status' => 'Hide' ,
'status' => 'Pending'
]);
if ( $opSellerForm ) {
$user = User :: find ( auth () -> guard ( 'users' ) -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Other Products' );
return response () -> json ([ 'status' => 200 , 'message' => " $request->product_category Form Submitted For Review " ]);
}
return response () -> json ([ 'status' => 400 , 'message' => " $request->product_category Form Could Not Be Submitted! " ]);
}
public function aifInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_aif_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_aif_sellers.id' )
-> alernativeInvestmentFund ()
-> where ( 'listing_status' , '!=' , 'Hide' )
2024-05-31 15:52:03 +05:30
-> notSold ()
// ->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
-> select (
'marketplace_buyer_forms.*' , // Select all columns from marketplace_aif_sellers
'marketplace_aif_sellers.name_of_the_aif_fund' ,
2024-06-03 12:55:29 +05:30
'marketplace_aif_sellers.slug' ,
2024-05-31 15:52:03 +05:30
'marketplace_aif_sellers.fund_category' ,
'marketplace_aif_sellers.fund_strategy' ,
'marketplace_aif_sellers.type_of_fund' ,
'marketplace_aif_sellers.total_capital_commitment' ,
'marketplace_aif_sellers.uncalled_capital_commitment'
)
2024-03-28 14:52:40 +05:30
-> get ();
2024-05-31 15:52:03 +05:30
// $data['data'] = MarketplaceBuyerForm::has('aifSellerData')->with('aifSellerData')->alernativeInvestmentFund()->notSold()->get();
// dd($data['data']->toArray());
2024-03-28 14:52:40 +05:30
return $data ;
}
public function freInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
2024-05-10 11:52:09 +05:30
// ->leftJoin('compaines', 'marketplace_fre_sellers.fractional_real_estate_platform', 'compaines.id')
2024-03-28 14:52:40 +05:30
-> join ( 'marketplace_fre_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_fre_sellers.id' )
2024-05-10 11:52:09 +05:30
// ->with('compaines')
2024-03-28 14:52:40 +05:30
-> fractionalRealEstate ()
-> where ( 'listing_status' , '!=' , 'Hide' )
2024-05-31 15:52:03 +05:30
-> notSold ()
// ->select('property_name', 'property_address', 'property_grade', 'asset_type', 'fractional_real_estate_platform', 'expected_selling_price')
-> select (
'marketplace_buyer_forms.*' , // Select all columns from marketplace_aif_sellers
'marketplace_fre_sellers.property_name' ,
2024-06-03 12:55:29 +05:30
'marketplace_fre_sellers.slug' ,
2024-05-31 15:52:03 +05:30
'marketplace_fre_sellers.property_address' ,
'marketplace_fre_sellers.property_grade' ,
'marketplace_fre_sellers.asset_type' ,
'marketplace_fre_sellers.fractional_real_estate_platform' ,
'marketplace_fre_sellers.expected_selling_price'
)
2024-03-28 14:52:40 +05:30
-> get ();
2024-05-10 11:52:09 +05:30
$data [ 'data' ] -> each ( function ( $value ){
if ( $value -> fractional_real_estate_platform != null )
{
$value -> company_name = Company :: where ( 'id' , $value -> fractional_real_estate_platform ) -> value ( 'company_name' );
}
});
2024-03-28 14:52:40 +05:30
return $data ;
}
public function opInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_op_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_op_sellers.id' )
-> otherProducts ()
-> where ( 'listing_status' , '!=' , 'Hide' )
-> select ( 'product_category' , 'security_name' , 'instrument_type' , 'instrument_issuer' , 'credit_rating' , 'expected_sale_price_per_unit' )
-> get ();
return $data ;
}
public function aifSoldInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_aif_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_aif_sellers.id' )
-> alernativeInvestmentFund ()
-> sold ()
2024-04-26 12:23:43 +05:30
// ->where('listing_status', '!=', 'Hide')
2024-04-19 15:16:12 +05:30
// ->where('marketplace_aif_sellers.listing_status', 'Hide')
2024-03-28 14:52:40 +05:30
-> select ( 'name_of_the_aif_fund' , 'fund_category' , 'fund_strategy' , 'type_of_fund' , 'total_capital_commitment' , 'uncalled_capital_commitment' )
-> get ();
2024-04-19 15:16:12 +05:30
// dd($data);
2024-03-28 14:52:40 +05:30
return $data ;
}
public function freSoldInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_fre_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_fre_sellers.id' )
-> fractionalRealEstate ()
-> sold ()
2024-04-26 12:23:43 +05:30
// ->where('listing_status', '!=', 'Hide')
2024-04-19 15:16:12 +05:30
// ->where('marketplace_fre_sellers.listing_status', 'Hide')
2024-03-28 14:52:40 +05:30
-> select ( 'property_name' , 'property_address' , 'property_grade' , 'asset_type' , 'fractional_real_estate_platform' , 'expected_selling_price' )
-> get ();
2024-05-10 11:52:09 +05:30
$data [ 'data' ] -> each ( function ( $value ){
if ( $value -> fractional_real_estate_platform != null )
{
$value -> company_name = Company :: where ( 'id' , $value -> fractional_real_estate_platform ) -> value ( 'company_name' );
}
});
2024-03-28 14:52:40 +05:30
return $data ;
}
public function opSoldInvestmentWatchlist ()
{
$data [ 'data' ] = MarketplaceBuyerForm :: query ()
-> join ( 'marketplace_op_sellers' , 'marketplace_buyer_forms.associated_id' , 'marketplace_op_sellers.id' )
-> otherProducts ()
-> sold ()
-> where ( 'listing_status' , '!=' , 'Hide' )
-> select ( 'product_category' , 'security_name' , 'instrument_type' , 'instrument_issuer' , 'credit_rating' , 'expected_sale_price_per_unit' )
-> get ();
2024-05-02 14:50:31 +05:30
// dd($data);
2024-03-28 14:52:40 +05:30
return $data ;
}
public function aifInvestmentListed ()
{
$data [ 'data' ] = MarketplaceSellerForm :: query ()
-> where ( 'marketplace_seller_forms.users_id' , auth () -> guard ( 'users' ) -> user () -> id )
-> join ( 'marketplace_aif_sellers' , 'marketplace_seller_forms.id' , 'marketplace_aif_sellers.seller_forms_id' )
2024-04-19 15:16:12 +05:30
-> where ( 'marketplace_aif_sellers.listing_status' , '!=' , 'Hide' )
2024-05-02 14:50:31 +05:30
// ->where('marketplace_aif_sellers.status', 'Approved')
2024-03-28 14:52:40 +05:30
-> select ( 'name_of_the_aif_fund' , 'fund_category' , 'fund_strategy' , 'type_of_fund' , 'total_capital_commitment' , 'uncalled_capital_commitment' )
-> get ();
2024-05-02 14:50:31 +05:30
// dd($data);
2024-04-19 15:16:12 +05:30
return $data ;
}
public function freInvestmentListed ()
{
$data [ 'data' ] = MarketplaceSellerForm :: query ()
2024-03-28 14:52:40 +05:30
-> where ( 'marketplace_seller_forms.users_id' , auth () -> guard ( 'users' ) -> user () -> id )
-> join ( 'marketplace_fre_sellers' , 'marketplace_seller_forms.id' , 'marketplace_fre_sellers.seller_forms_id' )
2024-04-19 15:16:12 +05:30
-> where ( 'marketplace_fre_sellers.listing_status' , '!=' , 'Hide' )
2024-05-02 14:50:31 +05:30
// ->where('marketplace_fre_sellers.status', 'Approved')
2024-03-28 14:52:40 +05:30
-> select ( 'property_name' , 'property_address' , 'property_grade' , 'asset_type' , 'fractional_real_estate_platform' , 'expected_selling_price' )
-> get ();
return $data ;
}
public function opInvestmentListed ()
{
$data [ 'data' ] = MarketplaceSellerForm :: query ()
-> where ( 'marketplace_seller_forms.users_id' , auth () -> guard ( 'users' ) -> user () -> id )
-> join ( 'marketplace_op_sellers' , 'marketplace_seller_forms.id' , 'marketplace_op_sellers.seller_forms_id' )
-> select ( 'product_category' , 'security_name' , 'instrument_type' , 'instrument_issuer' , 'credit_rating' , 'expected_sale_price_per_unit' )
-> get ();
return $data ;
}
public function sendNotificationToUser ( $name , $type )
{
$notify [ 'message' ] = " $name has submitted a seller form for $type ! " ;
$type = 'Seller Form' ;
$users = ModelsUser :: admins () -> get ();
foreach ( $users as $data ) {
$data -> notify ( new UserAdmin ( $notify , $type ));
}
}
public function getSellerForm ( Request $request , $custom_id = null )
{
if ( $custom_id ) {
$id = \Crypt :: decrypt ( $custom_id );
$data = MonthlyUpdateMaster :: with ( 'investor' ) -> where ( 'custom_id' , '=' , $id ) -> first ();
$category = $data -> categories ;
if ( $category == " Fractional Real Estate " ) {
$category = 'Fractional Real Estate' ;
} elseif ( $category == " Alternative Investment Fund " ) {
$category = 'Alternative Investment Fund' ;
} else {
$category = 'Other Products' ;
}
} else {
$data = '' ;
}
$userData = array ();
$marketPlaceSellerForm = MarketplaceSellerForm :: where ( 'users_id' , request () -> user () -> id ) -> first ();
$user = ModelsUser :: find ( request () -> user () -> id );
$contactNumber = $marketPlaceSellerForm -> contact_number ? ? $user -> contact_number ;
$userData [ 'data' ] = ( object )[
// 'encrypted_custom_id' => $custom_id,
'name' => $marketPlaceSellerForm -> name ? ? $user -> name ,
'city' => $marketPlaceSellerForm -> city ? ? null ,
'country' => $marketPlaceSellerForm -> country ? ? null ,
'postal_code' => $marketPlaceSellerForm -> postal_code ? ? null ,
'contact_number' => ( int ) $contactNumber ,
'email' => $marketPlaceSellerForm -> email ? ? $user -> email ,
'category' => $category ? ? null
// 'declaration' => $marketPlaceSellerForm->declaration ?? null,
];
return $userData ;
}
public function sellerFormSubmitAPI ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'name' => 'required' ,
'city' => 'required' ,
'country' => 'required' ,
'postal_code' => 'required' ,
'contact_number' => 'required|digits:10' ,
'email' => 'required' ,
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 15:39:11 +05:30
// $sellerFormUpdateCreate = MarketplaceSellerForm::updateOrCreate([
// 'users_id' => $request->user()->id
// ], [
// 'name' => $request->name,
// 'city' => $request->city,
// 'country' => $request->country,
// 'postal_code' => $request->postal_code,
// 'contact_number' => $request->contact_number,
// 'email' => $request->email,
// ]);
$data = [
2024-03-28 14:52:40 +05:30
'name' => $request -> name ,
'city' => $request -> city ,
'country' => $request -> country ,
'postal_code' => $request -> postal_code ,
'contact_number' => $request -> contact_number ,
'email' => $request -> email ,
2024-05-17 15:39:11 +05:30
];
session :: put ( 'sellerFormData' , $data );
if ( session :: has ( 'sellerFormData' )) {
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Seller Form Reviewed & Submitted!' ]);
2024-04-16 15:17:56 +05:30
// return response()->json(['status' => 200, 'message' => 'Thank you for submitting the seller form. Our team will promptly review your submission and keep you informed regarding the status of your product listing.']);
2024-03-28 14:52:40 +05:30
}
return response () -> json ([ 'status' => 400 , 'message' => 'Seller Form Could Not Be Reviewed & Submitted!' ]);
}
public function marketplaceAIFFormAPI ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'name_of_the_aif_fund' => 'required' ,
'fund_category' => 'required' ,
'fund_structure' => 'required' ,
'type_of_fund' => 'required' ,
'fund_strategy' => 'required' ,
'fund_manager_name' => 'required' ,
'sponsor' => 'required' ,
// 'credit_rating' => 'required',
'total_capital_commitment' => 'required' ,
'uncalled_capital_commitment' => 'required' ,
'date_of_final_close' => 'required' ,
'tenure_from_final_close' => 'required' ,
'current_or_latest_nav' => 'required' ,
'no_of_units_held' => 'required' ,
'no_of_units_you_wish_to_sell' => 'required' ,
'expected_sale_per_unit' => 'required' ,
2024-04-09 15:48:30 +05:30
'latest_valuation_date' => 'required' ,
2024-03-28 14:52:40 +05:30
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
2024-04-09 15:48:30 +05:30
2024-03-28 14:52:40 +05:30
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 15:39:11 +05:30
$sellerFormUpdateCreate = MarketplaceSellerForm :: updateOrCreate ([
'users_id' => auth () -> guard ( 'users' ) -> user () -> id
2024-05-29 16:29:37 +05:30
], session :: get ( 'sellerFormData' ));
2024-03-28 14:52:40 +05:30
$aifSellerForm = MarketplaceAlternativeInvestmentFundSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , $request -> user () -> id ) -> value ( 'id' ),
'name_of_the_aif_fund' => $request -> name_of_the_aif_fund ,
'slug' => SlugService :: createSlug ( MarketplaceAlternativeInvestmentFundSeller :: class , 'slug' , $request -> name_of_the_aif_fund ),
'fund_category' => $request -> fund_category ,
'fund_structure' => $request -> fund_structure ,
'type_of_fund' => $request -> type_of_fund ,
'fund_strategy' => $request -> fund_strategy ,
'fund_manager_name' => $request -> fund_manager_name ,
'sponsor' => $request -> sponsor ,
'credit_rating' => $request -> credit_rating ,
'total_capital_commitment' => $request -> total_capital_commitment ,
'uncalled_capital_commitment' => $request -> uncalled_capital_commitment ,
'date_of_final_close' => $request -> date_of_final_close ,
'tenure_from_final_close' => $request -> tenure_from_final_close ,
'current_or_latest_nav' => $request -> current_or_latest_nav ,
'no_of_units_held' => $request -> no_of_units_held ,
'no_of_units_you_wish_to_sell' => $request -> no_of_units_you_wish_to_sell ,
'expected_sale_per_unit' => $request -> expected_sale_per_unit ,
'listing_status' => 'Hide' ,
2024-04-09 15:48:30 +05:30
'status' => 'Pending' ,
'latest_valuation_date' => $request -> latest_valuation_date , //latest_valuation_date added by hritik on 09-04-24
2024-03-28 14:52:40 +05:30
]);
if ( $aifSellerForm ) {
$user = User :: find ( $request -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Alternative Investment Fund' );
2024-05-29 16:29:37 +05:30
session :: forget ( 'sellerFormData' );
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Alternative Investment Fund Form Submitted For Review' ]);
}
return response () -> json ([ 'status' => 400 , 'message' => 'Alternative Investment Fund Form Could Not Be Submitted!' ]);
}
public function marketplaceFREFormAPI ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'property_name' => 'required' ,
'property_address' => 'required' ,
'property_grade' => 'required' ,
'asset_type' => 'required' ,
'annual_rental_yield_earned' => 'required' ,
'rental_escalation' => 'required' ,
'fractional_real_estate_platform' => 'required' ,
'date_of_investment' => 'required' ,
'original_amount_invested' => 'required' ,
'current_market_value_of_the_property' => 'required' ,
'expected_selling_price' => 'required' ,
2024-04-09 15:48:30 +05:30
'latest_valuation_date' => 'required' ,
2024-03-28 14:52:40 +05:30
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
2024-05-17 15:39:11 +05:30
$sellerFormUpdateCreate = MarketplaceSellerForm :: updateOrCreate ([
'users_id' => auth () -> guard ( 'users' ) -> user () -> id
2024-05-29 16:29:37 +05:30
], session :: get ( 'sellerFormData' ));
2024-03-28 14:52:40 +05:30
2024-05-17 15:39:11 +05:30
// dd($request->all(),$request->user()->id,request()->user()->id);
2024-03-28 14:52:40 +05:30
$freSellerForm = MarketplaceFractionalRealEstateSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , $request -> user () -> id ) -> value ( 'id' ),
'property_name' => $request -> property_name ,
'slug' => SlugService :: createSlug ( MarketplaceFractionalRealEstateSeller :: class , 'slug' , $request -> property_name ),
'property_address' => $request -> property_address ,
'property_grade' => $request -> property_grade ,
'asset_type' => $request -> asset_type ,
'annual_rental_yield_earned' => $request -> annual_rental_yield_earned ,
'rental_escalation' => $request -> rental_escalation ,
'fractional_real_estate_platform' => $request -> fractional_real_estate_platform ,
'date_of_investment' => $request -> date_of_investment ,
'original_amount_invested' => $request -> original_amount_invested ,
'current_market_value_of_the_property' => $request -> current_market_value_of_the_property ,
'expected_selling_price' => $request -> expected_selling_price ,
'listing_status' => 'Hide' ,
2024-04-09 15:48:30 +05:30
'status' => 'Pending' ,
'latest_valuation_date' => $request -> latest_valuation_date , //latest_valuation_date added by hritik on 09-04-24
2024-03-28 14:52:40 +05:30
]);
if ( $freSellerForm ) {
$user = User :: find ( $request -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Fractional Real Estate' );
2024-05-29 16:29:37 +05:30
session :: forget ( 'sellerFormData' );
2024-03-28 14:52:40 +05:30
return response () -> json ([ 'status' => 200 , 'message' => 'Fractional Real Estate Form Submitted For Review' ]);
}
return response () -> json ([ 'status' => 400 , 'message' => 'Fractional Real Estate Form Could Not Be Submitted!' ]);
}
public function marketplaceOPFormAPI ( Request $request )
{
$validator = Validator :: make ( $request -> all (), [
'product_category' => 'required' ,
'security_name' => 'required' ,
'instrument_type' => 'required' ,
'instrument_issuer' => 'required' ,
'isin' => 'required' ,
'credit_rating' => 'required' ,
'listed' => 'required' ,
'date_of_original_investment' => 'required' ,
'amount_invested' => 'required' ,
'no_of_units_held' => 'required' ,
'payout_frequency' => 'required' ,
'face_value_per_unit' => 'required' ,
'coupon_rate_in_pct' => 'required' ,
'maturity_date' => 'required' ,
'no_of_units_offered_for_sale' => 'required' ,
'expected_sale_price_per_unit' => 'required' ,
], [
'required' => 'The :attribute field must be required' ,
'unique' => 'The :attribute field should be unique'
]);
$validationMessage = $this -> validationError ( $validator );
if ( $validationMessage ) {
return response () -> json ([ 'status' => 400 , 'message' => $validationMessage ]);
}
$opSellerForm = MarketplaceOtherProductsSeller :: create ([
'seller_forms_id' => MarketplaceSellerForm :: where ( 'users_id' , $request -> user () -> id ) -> value ( 'id' ),
'product_category' => $request -> product_category ,
'security_name' => $request -> security_name ,
'slug' => SlugService :: createSlug ( MarketplaceOtherProductsSeller :: class , 'slug' , $request -> security_name ),
'instrument_type' => $request -> instrument_type ,
'instrument_issuer' => $request -> instrument_issuer ,
'isin' => $request -> isin ,
'date_of_original_investment' => $request -> date_of_original_investment ,
'listed' => $request -> listed ,
'credit_rating' => $request -> credit_rating ,
'amount_invested' => $request -> amount_invested ,
'principal_repaid' => $request -> principal_repaid ,
'payout_frequency' => $request -> payout_frequency ,
'face_value_per_unit' => $request -> face_value_per_unit ,
'coupon_rate_in_pct' => $request -> coupon_rate_in_pct ,
'no_of_units_held' => $request -> no_of_units_held ,
'maturity_date' => $request -> maturity_date ,
'no_of_units_offered_for_sale' => $request -> no_of_units_offered_for_sale ,
'expected_sale_price_per_unit' => $request -> expected_sale_price_per_unit ,
'listing_status' => 'Hide' ,
'status' => 'Pending'
]);
if ( $opSellerForm ) {
$user = User :: find ( $request -> user () -> id );
$userNotify = $this -> sendNotificationToUser ( $user -> name , 'Other Products' );
return response () -> json ([ 'status' => 200 , 'message' => " $request->product_category Form Submitted For Review " ]);
}
return response () -> json ([ 'status' => 400 , 'message' => " $request->product_category Form Could Not Be Submitted! " ]);
}
public function validationError ( $validator )
{
if ( $validator -> fails ()) {
$errors = $validator -> errors ();
$messages = '' ;
foreach ( $errors -> all () as $message ) {
$messages .= $message . '</br>' ;
}
return $messages ;
}
}
// public function marketListView(Request $request)
// {
// // dd($request->category);
// $data =
// $page = '';
// if($request->category == "Fractional Real Estate")
// {
// // return view('Frontend.Pages.profile.market-list.fractional-real-estate');
// $page .= "/fractional-real-estate-market-list";
// }
// elseif($request->category == "Alternative Investment Fund")
// {
// // return view('Frontend.Pages.profile.market-list.alternative-investment-fund');
// $page .= "/alternative-investment-fund-market-list";
// }
// elseif($request->category == "others")
// {
// // return view('Frontend.Pages.profile.market-list.other-investment');
// $page .= "/market-list-other-market-list-view";
// }
// return response()->json(
// [
// "page"=>$page
// ]
// );
// }
}