381 lines
18 KiB
PHP
381 lines
18 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use App\Models\Chat;
|
|
use App\Models\Company;
|
|
use App\Models\Content;
|
|
use App\Models\Product;
|
|
use App\Models\Category;
|
|
use App\Models\Admin\Blog;
|
|
use App\Models\Admin\Testimonial;
|
|
use App\Models\MonthlyUpdateMaster;
|
|
use App\Models\MarketplaceBuyerForm;
|
|
use App\Models\MarketplaceSellerForm;
|
|
use App\Models\ProductTrailCommission;
|
|
use App\Models\MonthlyUpdatePeerToPeerLending;
|
|
use App\Models\MarketplaceOtherProductsSeller;
|
|
use App\Models\MonthlyUpdateFractionalRealEstate;
|
|
use App\Models\MonthlyUpdateIndianFinancialAssets;
|
|
use App\Models\MonthlyUpdateAlternativeInvestmentFund;
|
|
use App\Models\MarketplaceFractionalRealEstateSeller;
|
|
use App\Models\MarketplaceAlternativeInvestmentFundSeller;
|
|
use App\Models\Iam_App_Resources;
|
|
|
|
// validation error message
|
|
if (!function_exists('validationErrorMessage')) {
|
|
function validationErrorMessage($validator)
|
|
{
|
|
if ($validator->fails()) {
|
|
$errors = $validator->errors();
|
|
$messages = '';
|
|
foreach ($errors->all() as $message) {
|
|
$messages .= $message . '</br>';
|
|
}
|
|
return $messages;
|
|
}
|
|
}
|
|
}
|
|
|
|
function imagePath($path = null)
|
|
{
|
|
if (env('APP_ENV') == 'production') {
|
|
$finalPath = "https://jerichoalternatives.in/";
|
|
}
|
|
if (env('APP_ENV') == 'staging') {
|
|
$finalPath = "https://staging.jerichoalternatives.in/";
|
|
}
|
|
if (env('APP_ENV') == 'local') {
|
|
$finalPath = "http://localhost/freeu/my-freeu/";
|
|
}
|
|
return $finalPath . $path;
|
|
}
|
|
|
|
function routeForHandpickedInvestment($categoryId)
|
|
{
|
|
// return $categoryId;
|
|
// $routes = [
|
|
// // Category::HighYieldFinanceId => 'high-yield-finance.product',
|
|
// Category::FractionalRealEstateId => 'fractional-real-estate.product',
|
|
// // Category::PeerToPeerLendingId => 'peer-to-peer-lending.product',
|
|
// Category::VentureDebtId => 'venture-debts.product',
|
|
// Category::IndianResidentialRealEstateID => 'ire.product',
|
|
// Category::IndianCommercialRealEstateID => 'ire.product',
|
|
// Category::IndianIndustrialRealEstateID => 'ire.product',
|
|
// Category::GlobalResidentialRealEstateID => 'gre.product',
|
|
// Category::GlobalCommercialRealEstateID => 'gre.product',
|
|
// Category::GlobalIndustrialRealEstateID => 'gre.product',
|
|
// // Category::LeaseBasedFinancingId => 'lease-based-financing.product',
|
|
// // Category::SecuritizedDebtInstrumentId => 'securitized-debt-instrument.product',
|
|
// // Category::CleanAndGreenAssetsId => 'clean-and-green-assets.product',
|
|
// // Category::InvoiceDiscountingId => 'invoice-discounting.product',
|
|
// Category::VentureCapitalFundId => 'alternative-investment-fund.venture-capital-fund-product',
|
|
// Category::InfrastructureFundId => 'alternative-investment-fund.venture-capital-fund-product',
|
|
// Category::AngelFundId => 'alternative-investment-fund.angel-fund-product',
|
|
// Category::PrivateEquityFundId => 'alternative-investment-fund.private-equity-fund-product',
|
|
// Category::DebtFundId => 'alternative-investment-fund.debt-fund-product',
|
|
// Category::PrivateRealEstateFundId => 'alternative-investment-fund.private-real-estate-fund-product',
|
|
// Category::HedgeFundId => 'alternative-investment-fund.hedge-fund-product',
|
|
// Category::PrivateInvestmentInPublicEquityFundId => 'alternative-investment-fund.private-investment-public-equity-product',
|
|
// Category::SovereignGovernmentBondId => 'bonds.product',
|
|
// Category::GlobalMutualFundId => 'mutual-funds.product',
|
|
// Category::EquitiesId => 'equities.product',
|
|
// Category::GlobalHedgeFundId => 'hedge-funds.product',
|
|
// // Category::InfrastructureFundId => 'alternative-investment-fund.',
|
|
// //Change below code later
|
|
// //
|
|
// ];
|
|
|
|
$routes = [
|
|
Category::HighYieldFinanceId => 'high-yield-finance.product',
|
|
Category::FractionalRealEstateId => 'fractional-real-estate.product',
|
|
Category::PeerToPeerLendingId => 'peer-to-peer-lending.product',
|
|
Category::VentureDebtId => 'venture-debts.product',
|
|
Category::IndianResidentialRealEstateID => 'ire.product',
|
|
Category::IndianCommercialRealEstateID => 'ire.product',
|
|
Category::IndianIndustrialRealEstateID => 'ire.product',
|
|
Category::GlobalResidentialRealEstateID => 'gre.product',
|
|
Category::GlobalCommercialRealEstateID => 'gre.product',
|
|
Category::GlobalIndustrialRealEstateID => 'gre.product',
|
|
Category::LeaseBasedFinancingId => 'lease-based-financing.product',
|
|
Category::SecuritizedDebtInstrumentId => 'securitized-debt-instrument.product',
|
|
Category::CleanAndGreenAssetsId => 'clean-and-green-assets.product',
|
|
Category::InvoiceDiscountingId => 'invoice-discounting.product',
|
|
Category::VentureCapitalFundId => 'alternative-investment-fund.venture-capital-fund-product',
|
|
Category::GlobalVentureCapitalFundId => 'alternative-investment-fund.venture-capital-fund-product',
|
|
Category::InfrastructureFundId => 'alternative-investment-fund.infrastructure-fund-product',
|
|
Category::FundForDistressedAssetId => 'alternative-investment-fund.fund-for-distressed-asset-product',
|
|
Category::AngelFundId => 'alternative-investment-fund.angel-fund-product',
|
|
Category::PrivateEquityFundId => 'alternative-investment-fund.private-equity-fund-product',
|
|
Category::GlobalPrivateEquityFundId => 'alternative-investment-fund.private-equity-fund-product',
|
|
Category::PrivateCreditFundId => 'alternative-investment-fund.private-credit-fund-product',
|
|
Category::GlobalPrivateCreditFundId => 'global-private-credit-fund-product',
|
|
Category::PrivateRealEstateFundId => 'alternative-investment-fund.private-real-estate-fund-product',
|
|
Category::HedgeFundId => 'alternative-investment-fund.hedge-fund-product',
|
|
// Category::LongOnlyFundId => 'alternative-investment-fund.hedge-fund-product',
|
|
Category::LongOnlyFundId => 'alternative-investment-fund.long-only-equity-fund-product',
|
|
Category::PrivateInvestmentInPublicEquityFundId => 'alternative-investment-fund.private-investment-public-equity-product',
|
|
Category::SovereignGovernmentBondId => 'bonds.product',
|
|
Category::GlobalMutualFundId => 'mutual-funds.product',
|
|
Category::EquitiesId => 'equities.product',
|
|
Category::GlobalHedgeFundId => 'hedge-funds.product',
|
|
];
|
|
|
|
return $routes[$categoryId];
|
|
// $condition = array_search($categoryId, $routes);
|
|
// return $condition == true ? $condition : 'venture-debts.product';
|
|
}
|
|
|
|
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 testimonial()
|
|
{
|
|
return Testimonial::where('is_active', true)->get();
|
|
}
|
|
|
|
function latestBlog()
|
|
{
|
|
return Blog::where('is_active', true)->take(3)->get();
|
|
}
|
|
|
|
function privacyPolicy()
|
|
{
|
|
return Content::where('type', 'privacy-policy')->value('content');
|
|
}
|
|
|
|
function termsConditions()
|
|
{
|
|
return Content::where('type', 'terms-and-condition')->value('content');
|
|
}
|
|
|
|
function getAllNotifications()
|
|
{
|
|
$user = User::find(auth()->guard('users')->user()->id);
|
|
return $user->unreadNotifications;
|
|
}
|
|
|
|
function getAllAdminNotifications()
|
|
{
|
|
// $arr = [];
|
|
// return $arr;
|
|
$user = User::find(auth()->user()->id);
|
|
return $user->unreadNotifications;
|
|
}
|
|
|
|
function getUserProfile()
|
|
{
|
|
if (!auth()->guard('users')->user()) {
|
|
return [
|
|
'name' => false,
|
|
'profile-image' => false
|
|
];
|
|
}
|
|
$user = User::find(auth()->guard('users')->user()->id);
|
|
if ($user) {
|
|
return [
|
|
'name' => $user->name,
|
|
'profile-image' => $user->profile_image
|
|
];
|
|
}
|
|
}
|
|
|
|
function getAdminProfile()
|
|
{
|
|
$user = User::find(auth()->user()->id);
|
|
return [
|
|
'name' => $user->name,
|
|
'email' => $user->email,
|
|
'profile-image' => $user->profile_image
|
|
];
|
|
}
|
|
|
|
function getAllProductNames($categoriesId = '')
|
|
{
|
|
return Product::leftJoin('securitized_debt_instruments as sdi', 'products.id', 'sdi.products_id')
|
|
->leftJoin('fractional_real_estates as fre', 'products.id', 'fre.products_id')
|
|
->leftJoin('peer_to_peer_lendings as p2p', 'products.id', 'p2p.products_id')
|
|
->leftJoin('invoice_discountings as id', 'products.id', 'id.products_id')
|
|
->leftJoin('alternative_investment_funds as aif', 'products.id', 'aif.products_id')
|
|
->leftJoin('clean_and_green_assets as caga', 'products.id', 'caga.products_id')
|
|
->leftJoin('high_yield_finances as hyf', 'products.id', 'hyf.products_id')
|
|
->leftJoin('lease_based_financings as lbf', 'products.id', 'lbf.products_id')
|
|
->leftJoin('venture_debts as vd', 'products.id', 'vd.products_id')
|
|
->leftJoin('bonds as bd', 'products.id', 'bd.products_id')
|
|
->leftJoin('funds as fd', 'products.id', 'fd.products_id')
|
|
->leftJoin('stock_funds_real_estate_exchanges as exchange', 'products.id', 'exchange.products_id')
|
|
->leftJoin('real_estates as re', 'products.id', 're.products_id')
|
|
->where('status', true)
|
|
->when($categoriesId !== '', function ($query) use ($categoriesId) {
|
|
$query->whereIn('categories_id', [$categoriesId]);
|
|
})
|
|
->select(\DB::raw('products.id,coalesce(sdi.product_name, p2p.scheme, fre.property_name_and_location,id.company_name,aif.fund_name,caga.project_name,hyf.security_name,lbf.company,sdi.product_name,vd.company_name,bd.issuer,fd.fund_name,exchange.name,re.property_name) as product_name'))->get();
|
|
}
|
|
|
|
function getAllSoldProducts($sellerFormId)
|
|
{
|
|
$productsSold = 0;
|
|
|
|
$marketplaceAIFPRoducts = MarketplaceAlternativeInvestmentFundSeller::where('seller_forms_id', $sellerFormId)->get();
|
|
foreach ($marketplaceAIFPRoducts as $data) {
|
|
if (MarketplaceBuyerForm::where(['table' => 'marketplace_aif_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) {
|
|
$productsSold++;
|
|
}
|
|
}
|
|
|
|
$marketplaceFREPRoducts = MarketplaceFractionalRealEstateSeller::where('seller_forms_id', $sellerFormId)->get();
|
|
foreach ($marketplaceFREPRoducts as $data) {
|
|
if (MarketplaceBuyerForm::where(['table' => 'marketplace_fre_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) {
|
|
$productsSold++;
|
|
}
|
|
}
|
|
|
|
$marketplaceOPPRoducts = MarketplaceOtherProductsSeller::where('seller_forms_id', $sellerFormId)->get();
|
|
foreach ($marketplaceOPPRoducts as $data) {
|
|
if (MarketplaceBuyerForm::where(['table' => 'marketplace_op_sellers', 'status' => 'Sold', 'associated_id' => $data->id])->exists()) {
|
|
$productsSold++;
|
|
}
|
|
}
|
|
return $productsSold;
|
|
}
|
|
|
|
function totalInvestmentCount($id)
|
|
{
|
|
return MonthlyUpdateMaster::where(['users_id' => $id, 'holding_status' => 'Holding'])->count();
|
|
}
|
|
|
|
function totalInvestment($id, $type = null)
|
|
{
|
|
// $user = MonthlyUpdateMaster::where('users_id', $id)->where('holding_status',$type)->get();
|
|
$user = MonthlyUpdateMaster::where('users_id', $id)->when($type !== null, function ($query) use ($type) {
|
|
return $query->where('holding_status', $type);
|
|
})->get();
|
|
|
|
$productDetails = [];
|
|
foreach ($user as $singleMUM) {
|
|
$dataArr = [
|
|
'categories' => $singleMUM->categories,
|
|
'product_category' => $singleMUM->product_category,
|
|
'product_name' => $singleMUM->product_name,
|
|
];
|
|
if (MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $singleMUM->custom_id)->exists()) {
|
|
$data = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $singleMUM->custom_id)->latest()->first();
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('commitment_amount');
|
|
array_push($productDetails, $dataArr);
|
|
} elseif (MonthlyUpdateFractionalRealEstate::where('custom_id', $singleMUM->custom_id)->first()) {
|
|
$data = MonthlyUpdateFractionalRealEstate::where('custom_id', $singleMUM->custom_id)->latest()->first();
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('absolute_return_till_date');
|
|
array_push($productDetails, $dataArr);
|
|
} elseif (MonthlyUpdatePeerToPeerLending::where('custom_id', $singleMUM->custom_id)->first()) {
|
|
$data = MonthlyUpdatePeerToPeerLending::where('custom_id', $singleMUM->custom_id)->latest()->first();
|
|
if ($singleMUM->categories == 'Liquiloans') {
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('total_investment');
|
|
} elseif ($singleMUM->categories == 'Faircent') {
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('all_time_amount_invested');
|
|
} elseif ($singleMUM->categories == 'Finance Peer') {
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('all_time_investment_added');
|
|
}
|
|
array_push($productDetails, $dataArr);
|
|
} elseif (MonthlyUpdateIndianFinancialAssets::where('custom_id', $singleMUM->custom_id)->first()) {
|
|
$data = MonthlyUpdateIndianFinancialAssets::where('custom_id', $singleMUM->custom_id)->latest()->first();
|
|
$dataArr['total_investment_amount'] = $data->amount_invested;
|
|
array_push($productDetails, $dataArr);
|
|
}
|
|
}
|
|
$totalInvestment = array_sum(array_column($productDetails, 'total_investment_amount'));
|
|
|
|
$totalInvestment = IND_money_format($totalInvestment);
|
|
|
|
return $totalInvestment;
|
|
}
|
|
|
|
function generateCommissionCount()
|
|
{
|
|
return ProductTrailCommission::whereDate('commission_date', '<=', now())->where('commission_earned', 'No')->count();
|
|
}
|
|
|
|
function riskDisclosureData()
|
|
{
|
|
return Content::where('type', 'terms-and-condition')->value('content');
|
|
}
|
|
|
|
function checkSidebarAccess($resource)
|
|
{
|
|
$user = User::with('getAppResourcesActionLink')->where('id', \Auth::user()->id)->first();
|
|
$sidebarSlugs = array();
|
|
foreach ($user->getAppResourcesActionLink as $userResource) {
|
|
$resourceSlug = Iam_App_Resources::find($userResource->app_resource_xid);
|
|
array_push($sidebarSlugs, $resourceSlug->slug);
|
|
}
|
|
if (in_array($resource, $sidebarSlugs) || $user->role == 1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function unreadChats()
|
|
{
|
|
$unreadChats = Chat::groupBy('user_id')->where('read_at', null)->get();
|
|
return count($unreadChats);
|
|
}
|
|
|
|
function companyName($id)
|
|
{
|
|
return Company::where('id', $id)->value('company_name');
|
|
}
|
|
|
|
function getCategoryIcons($categoryId)
|
|
{
|
|
$category_icons = [
|
|
"public/assets/media/FrontendImages/fract-state.svg" => Category::FractionalRealEstateId,
|
|
"public/assets/media/FrontendImages/capital-funds.svg" => Category::VentureCapitalFundId, // aif product icons start from here
|
|
"public/assets/media/FrontendImages/comm-real-state.svg" => Category::IndianCommercialRealEstateID,
|
|
"public/assets/media/FrontendImages/stra-fund.svg" => Category::HedgeFundId,
|
|
"public/assets/media/FrontendImages/assets-funds.svg" => Category::FundForDistressedAssetId, // new category start from here
|
|
"public/assets/media/FrontendImages/private.svg" => Category::PrivateRealEstateFundId,
|
|
"public/assets/media/FrontendImages/bay-arrow.svg" => Category::LongOnlyFundId,
|
|
"public/assets/media/FrontendImages/Infr-funds.svg" => Category::InfrastructureFundId,
|
|
"public/assets/media/FrontendImages/cradit-funds.svg" => Category::PrivateCreditFundId,
|
|
// "public/assets/media/FrontendImages/cradit-funds.svg" => 40,
|
|
"public/assets/media/FrontendImages/equity-funds.svg" => Category::PrivateEquityFundId,
|
|
"public/assets/media/FrontendImages/angel-funds.svg" => Category::AngelFundId,
|
|
"public/assets/media/FrontendImages/stra-fund.svg" => Category::HedgeFundId,
|
|
"public/assets/media/FrontendImages/pipe-funds.svg" => Category::PrivateInvestmentInPublicEquityFundId,
|
|
"public/assets/media/FrontendImages/stra-fund.svg" => Category::GlobalHedgeFundId, //global product icons start from here
|
|
"public/assets/media/FrontendImages/cradit-funds.svg" => Category::GlobalPrivateCreditFundId,
|
|
"public/assets/media/FrontendImages/equity-funds.svg" => Category::GlobalPrivateEquityFundId,
|
|
"public/assets/media/FrontendImages/capital-funds.svg" => Category::GlobalVentureCapitalFundId,
|
|
"public/assets/media/FrontendImages/login-img/alternative.svg" => Category::IndianIndustrialRealEstateID, // indain real estate start from here
|
|
"public/assets/media/FrontendImages/resi-real-state.svg" => Category::IndianResidentialRealEstateID,
|
|
"public/assets/media/FrontendImages/comm-real-state.svg" => Category::IndianCommercialRealEstateID,
|
|
"public/assets/media/FrontendImages/login-img/alternative.svg" => Category::GlobalIndustrialRealEstateID, // global real estate start from here
|
|
"public/assets/media/FrontendImages/resi-real-state.svg" => Category::GlobalResidentialRealEstateID,
|
|
"public/assets/media/FrontendImages/comm-real-state.svg" => Category::GlobalCommercialRealEstateID,
|
|
];
|
|
$condition = array_search($categoryId, $category_icons);
|
|
return $condition == true ? $condition : 'public/assets/media/FrontendImages/bay-arrow.svg';
|
|
}
|