1173 lines
57 KiB
PHP
1173 lines
57 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Admin\User;
|
|
use App\Models\AlternativeInvestmentFund;
|
|
use App\Models\Company;
|
|
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;
|
|
use DB;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$user = $this->getUser()->data;
|
|
$currentInvestmentProduct = $this->view_investors_details('Holding');
|
|
$reedemedInvestmentProduct = $this->view_investors_details('Reedemed');
|
|
// watchlist
|
|
$aifInvestmentWatchlist = $this->aifInvestmentWatchlist()['data'];
|
|
$freInvestmentWatchlist = $this->freInvestmentWatchlist()['data'];
|
|
$opInvestmentWatchlist = $this->opInvestmentWatchlist()['data'];
|
|
// sold
|
|
$aifSoldInvestmentWatchlist = $this->aifSoldInvestmentWatchlist()['data'];
|
|
$freSoldInvestmentWatchlist = $this->freSoldInvestmentWatchlist()['data'];
|
|
$opSoldInvestmentWatchlist = $this->opSoldInvestmentWatchlist()['data'];
|
|
// bought
|
|
$aifInvestmentListed = $this->aifInvestmentListed()['data'];
|
|
$freInvestmentListed = $this->freInvestmentListed()['data'];
|
|
$opInvestmentListed = $this->opInvestmentListed()['data'];
|
|
//
|
|
$marketPlaceAIFSellerData = $this->getMarketplaceAIFSellerData(1);
|
|
$marketPlaceFRESellerData = $this->getMarketplaceFRESellerData(1);
|
|
// dd($marketPlaceFRESellerData);
|
|
$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'));
|
|
}
|
|
|
|
public function getMarketplaceAIFSellerData($api = null)
|
|
{
|
|
$id = auth()->guard('users')->user()->id ?? request()->user()->id;
|
|
// $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;
|
|
// $sellerData = MarketplaceSellerForm::has('aif')->with('aif')->where('users_id',$id)->get();
|
|
$sellerData = MarketplaceSellerForm::with('aif')->where('users_id',$id)->get();
|
|
// dd($sellerData);
|
|
// return $sellerData[0]->aif['name_of_the_aif_fund'];
|
|
// return $api;
|
|
if($api == null)
|
|
{
|
|
$data['data'] = $sellerData;
|
|
return $data;
|
|
}
|
|
if(count($sellerData->toArray()))
|
|
{
|
|
$market_place_data = $sellerData[0]->aif->toArray();
|
|
// dd($market_place_data);
|
|
return $market_place_data;
|
|
}
|
|
return $sellerData;
|
|
|
|
}
|
|
|
|
public function aifSoldInvestment()
|
|
{
|
|
$data['data'] = MarketplaceBuyerForm::query()
|
|
->join('marketplace_aif_sellers', 'marketplace_buyer_forms.associated_id', 'marketplace_aif_sellers.id')
|
|
->alernativeInvestmentFund()
|
|
->sold()
|
|
->where('listing_status', '!=', 'Hide')
|
|
->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;
|
|
}
|
|
|
|
public function getMarketplaceFRESellerData($api = null)
|
|
{
|
|
$id = auth()->guard('users')->user()->id ?? request()->user()->id;
|
|
// $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;
|
|
$sellerData = MarketplaceSellerForm::with('fre')->where('users_id',$id)->get();
|
|
// dd(count($sellerData->toArray()));
|
|
if($api == null)
|
|
{
|
|
$data['data'] = $sellerData;
|
|
return $data;
|
|
}
|
|
if(count($sellerData->toArray()))
|
|
{
|
|
$market_place_data = $sellerData[0]->fre->toArray();
|
|
return $market_place_data;
|
|
}
|
|
return $sellerData;
|
|
// if($sellerData->toArray()->count())
|
|
}
|
|
|
|
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();
|
|
$investmentArr = $this->totalInvestmentAmount_api($singleMUM, $data->getRawOriginal('absolute_return_till_date'));
|
|
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();
|
|
$investmentArr = $this->totalInvestmentAmount($singleMUM, $data->getRawOriginal('absolute_return_till_date'));
|
|
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,
|
|
'company_logo' => Company::find($singleMUM->investment_platform)->value('company_logo'),
|
|
'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'),
|
|
'company_name' => Company::find($singleMUM->investment_platform)->value('company_name'),
|
|
'route_id' => \Crypt::encrypt($singleMUM->custom_id)
|
|
];
|
|
$dataArr['total_investment_amount'] = $amount;
|
|
$dataArr['total_investment_amount_display'] = '₹ ' . $this->IND_money_format($amount);
|
|
return $dataArr;
|
|
}
|
|
|
|
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,
|
|
'company_logo' => Company::find($singleMUM->investment_platform)->value('company_logo'),
|
|
'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);
|
|
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();
|
|
$data['basic-details'] = $monthlyUpdateMaster;
|
|
$data['company_name'] = Company::find($monthlyUpdateMaster->investment_platform)->value('company_name');
|
|
$data['company_logo'] = Company::find($monthlyUpdateMaster->investment_platform)->value('company_logo');
|
|
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);
|
|
}
|
|
|
|
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") {
|
|
$data['category'] = 'Fractional Real Estate';
|
|
} elseif ($category == "Alternative Investment Fund") {
|
|
$data['category'] = 'Alternative Investment Fund';
|
|
} else {
|
|
$data['category'] = 'Other Products';
|
|
}
|
|
} else {
|
|
$data = '';
|
|
}
|
|
|
|
$userKyc = UserKyc::where('users_id', auth()->guard('users')->user()->id)->exists();
|
|
$userData = array();
|
|
if ($userKyc) {
|
|
$marketPlaceSellerForm = MarketplaceSellerForm::where('users_id', auth()->guard('users')->user()->id)->first();
|
|
$user = ModelsUser::find(auth()->guard('users')->user()->id);
|
|
// $userData = (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' => $marketPlaceSellerForm->contact_number ?? $user->contact_number,
|
|
// 'email' => $marketPlaceSellerForm->email ?? $user->email,
|
|
// 'declaration' => $marketPlaceSellerForm->declaration ?? null,
|
|
// ];
|
|
}
|
|
$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,
|
|
];
|
|
return view('Frontend.Pages.profile.market-list.sale-form', compact('data', 'userData'));
|
|
}
|
|
|
|
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]);
|
|
}
|
|
|
|
$sellerFormUpdateCreate = MarketplaceSellerForm::updateOrCreate([
|
|
'users_id' => auth()->guard('users')->user()->id
|
|
], [
|
|
'name' => $request->name,
|
|
'city' => $request->city,
|
|
'country' => $request->country,
|
|
'postal_code' => $request->postal_code,
|
|
'contact_number' => $request->contact_number,
|
|
'email' => $request->email,
|
|
]);
|
|
if ($sellerFormUpdateCreate) {
|
|
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)
|
|
{
|
|
if (MarketplaceSellerForm::where('users_id', auth()->guard('users')->user()->id)->where('status', true)->doesntExist()) {
|
|
abort(403);
|
|
}
|
|
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();
|
|
|
|
$monthlyUpdateMaster = MonthlyUpdateMaster::where(['custom_id' => \Crypt::decrypt($custom_id), 'users_id' => auth()->guard('users')->user()->id])->first();
|
|
}
|
|
|
|
|
|
$aifProduct = (object)[
|
|
// '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)
|
|
{
|
|
if (MarketplaceSellerForm::where('users_id', auth()->guard('users')->user()->id)->where('status', true)->doesntExist()) {
|
|
abort(403);
|
|
}
|
|
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)
|
|
{
|
|
$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',
|
|
'latest_valuation_date' => '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]);
|
|
}
|
|
|
|
$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,
|
|
'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,
|
|
'latest_valuation_date' => $request->latest_valuation_date,
|
|
'listing_status' => 'Hide',
|
|
'status' => 'Pending'
|
|
]);
|
|
if ($aifSellerForm) {
|
|
$user = User::find(auth()->guard('users')->user()->id);
|
|
$userNotify = $this->sendNotificationToUser($user->name, 'Alternative Investment Fund');
|
|
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',
|
|
'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',
|
|
'latest_valuation_date' => '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]);
|
|
}
|
|
|
|
$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,
|
|
'latest_valuation_date' => $request->latest_valuation_date,
|
|
'listing_status' => 'Hide',
|
|
'status' => 'Pending'
|
|
]);
|
|
if ($freSellerForm) {
|
|
$user = User::find(auth()->guard('users')->user()->id);
|
|
$userNotify = $this->sendNotificationToUser($user->name, 'Fractional Real Estate');
|
|
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')
|
|
->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
|
|
->get();
|
|
return $data;
|
|
}
|
|
|
|
public function freInvestmentWatchlist()
|
|
{
|
|
$data['data'] = MarketplaceBuyerForm::query()
|
|
->join('marketplace_fre_sellers', 'marketplace_buyer_forms.associated_id', 'marketplace_fre_sellers.id')
|
|
->fractionalRealEstate()
|
|
->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 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()
|
|
// ->where('listing_status', '!=', 'Hide')
|
|
// ->where('marketplace_aif_sellers.listing_status', 'Hide')
|
|
->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
|
|
->get();
|
|
// dd($data);
|
|
return $data;
|
|
}
|
|
|
|
public function freSoldInvestmentWatchlist()
|
|
{
|
|
$data['data'] = MarketplaceBuyerForm::query()
|
|
->join('marketplace_fre_sellers', 'marketplace_buyer_forms.associated_id', 'marketplace_fre_sellers.id')
|
|
->fractionalRealEstate()
|
|
->sold()
|
|
// ->where('listing_status', '!=', 'Hide')
|
|
// ->where('marketplace_fre_sellers.listing_status', 'Hide')
|
|
->select('property_name', 'property_address', 'property_grade', 'asset_type', 'fractional_real_estate_platform', 'expected_selling_price')
|
|
->get();
|
|
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();
|
|
// dd($data);
|
|
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')
|
|
->where('marketplace_aif_sellers.listing_status', '!=', 'Hide')
|
|
// ->where('marketplace_aif_sellers.status', 'Approved')
|
|
->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
|
|
->get();
|
|
// dd($data);
|
|
return $data;
|
|
}
|
|
|
|
public function freInvestmentListed()
|
|
{
|
|
$data['data'] = MarketplaceSellerForm::query()
|
|
->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')
|
|
->where('marketplace_fre_sellers.listing_status', '!=', 'Hide')
|
|
// ->where('marketplace_fre_sellers.status', 'Approved')
|
|
->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]);
|
|
}
|
|
|
|
$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,
|
|
]);
|
|
if ($sellerFormUpdateCreate) {
|
|
return response()->json(['status' => 200, 'message' => 'Seller Form Reviewed & Submitted!']);
|
|
// 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.']);
|
|
}
|
|
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',
|
|
'latest_valuation_date'=>'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]);
|
|
}
|
|
|
|
$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',
|
|
'status' => 'Pending',
|
|
'latest_valuation_date' => $request->latest_valuation_date, //latest_valuation_date added by hritik on 09-04-24
|
|
]);
|
|
if ($aifSellerForm) {
|
|
$user = User::find($request->user()->id);
|
|
$userNotify = $this->sendNotificationToUser($user->name, 'Alternative Investment Fund');
|
|
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',
|
|
'latest_valuation_date'=>'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]);
|
|
}
|
|
|
|
$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',
|
|
'status' => 'Pending',
|
|
'latest_valuation_date' => $request->latest_valuation_date, //latest_valuation_date added by hritik on 09-04-24
|
|
|
|
]);
|
|
if ($freSellerForm) {
|
|
$user = User::find($request->user()->id);
|
|
$userNotify = $this->sendNotificationToUser($user->name, 'Fractional Real Estate');
|
|
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
|
|
// ]
|
|
// );
|
|
// }
|
|
}
|