478 lines
26 KiB
PHP
478 lines
26 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use DataTables;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use App\Models\UserKyc;
|
|
use App\Models\UserKycDocs;
|
|
use App\Models\MonthlyUpdateMaster;
|
|
use App\Models\MonthlyUpdateAlternativeInvestmentFund;
|
|
use App\Models\MonthlyUpdateIndianFinancialAssets;
|
|
use App\Models\MonthlyUpdatePeerToPeerLending;
|
|
use App\Models\MonthlyUpdateFractionalRealEstate;
|
|
use App\Notifications\UserAdmin;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use App\Services\Admin\ContactUsService;
|
|
|
|
class ManageInvestorController extends Controller
|
|
{
|
|
protected $contact;
|
|
public function __construct(ContactUsService $contact)
|
|
{
|
|
$this->contact = $contact;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$check = checkSidebarAccess('manage-investors');
|
|
if (!$check) {
|
|
abort(404);
|
|
}
|
|
$users = User::with('activeInvestments')->users()->latest()->get();
|
|
$investingUserCount = MonthlyUpdateMaster::distinct('users_id')->count('users_id');
|
|
return view('Admin.Pages.manage_investors.manage_investors', compact('users', 'investingUserCount'));
|
|
}
|
|
|
|
public function replyInvestorMail(Request $request){
|
|
// dd($request->all());
|
|
$email = $request->email_send;
|
|
// $email = "ritikesh.yadav@wdimails.com";
|
|
$subject = $request->subject;
|
|
$reply = $request->reply;
|
|
$investorMail = True;
|
|
$success = $this->contact->sendMail($email, $subject, $reply, $investorMail);
|
|
return response()->json(['status'=>200,'message'=>'success']);
|
|
}
|
|
|
|
public function manage_investor_kyc()
|
|
{
|
|
$check = checkSidebarAccess('manage-investors-kyc');
|
|
if (!$check) {
|
|
abort(404);
|
|
}
|
|
$users = UserKyc::with('user')->get();
|
|
return view('Admin.Pages.manage_investors.manage_investor_kyc', compact('users'));
|
|
}
|
|
|
|
public function manageInvestorKYCIndividual($id)
|
|
{
|
|
$kycType = UserKyc::find($id)->kyc_type;
|
|
$userId = UserKyc::find($id)->users_id;
|
|
$user = UserKyc::query();
|
|
$user->where('user_kycs.id', $id);
|
|
if ($kycType == 'Individual') {
|
|
$user->leftJoin('user_individual_kyc', 'user_kycs.users_id', 'user_individual_kyc.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
if ($kycType == 'HUF') {
|
|
$user->leftJoin('huf', 'user_kycs.users_id', 'huf.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
if ($kycType == 'NRI') {
|
|
$user->leftJoin('nri_kyc', 'user_kycs.users_id', 'nri_kyc.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
if ($kycType == 'Company') {
|
|
$user->leftJoin('company', 'user_kycs.users_id', 'company.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
if ($kycType == 'Partnership') {
|
|
$user->leftJoin('partnership', 'user_kycs.users_id', 'partnership.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
if ($kycType == 'Others') {
|
|
$user->leftJoin('others', 'user_kycs.users_id', 'others.user_id');
|
|
// $user = $user->select('*')->first();
|
|
}
|
|
$user = $user->select('*')->first();
|
|
// $user->select('*')->first();
|
|
// $user = $user->addSelect('*')->first();
|
|
// $user = UserKyc::query()
|
|
// ->leftJoin('user_individual_kyc', 'user_kycs.users_id', 'user_individual_kyc.user_id')
|
|
// ->leftJoin('nri_kyc', 'user_kycs.users_id', 'nri_kyc.user_id')
|
|
// ->leftJoin('others', 'user_kycs.users_id', 'others.user_id')
|
|
// ->leftJoin('partnership', 'user_kycs.users_id', 'partnership.user_id')
|
|
// ->leftJoin('huf', 'user_kycs.users_id', 'huf.user_id')
|
|
// ->leftJoin('company', 'user_kycs.users_id', 'company.user_id')
|
|
// ->where('user_kycs.id', $id)
|
|
// ->select('*', 'user_individual_kyc.pan_card as individual_pan_card', 'huf.pan_card as huf_pan_card','user_individual_kyc.copy_of_cml as individual_copy_of_cml','huf.copy_of_cml as huf_copy_of_cml','huf.cancelled_cheque as huf_cancelled_cheque')
|
|
// ->first();
|
|
$user_docs = UserKycDocs::where('user_id', $userId)->get();
|
|
$userPan = UserKycDocs::where(['user_id' => $userId, 'doc_type' => 'Pan'])->get();
|
|
$userAadhar = UserKycDocs::where(['user_id' => $userId, 'doc_type' => 'Aadhar'])->get();
|
|
$userPassport = UserKycDocs::where(['user_id' => $userId, 'doc_type' => 'Passport'])->get();
|
|
// dd($user);
|
|
return view('Admin.Pages.manage_investors.manage_investor_kyc_individual', compact('user', 'user_docs', 'userPan', 'userAadhar', 'userPassport'));
|
|
}
|
|
|
|
public function total_active_investors()
|
|
{
|
|
return view('Admin.Pages.manage_investors.total_active_investors');
|
|
}
|
|
|
|
public function new_investors()
|
|
{
|
|
return view('Admin.Pages.manage_investors.new_investors');
|
|
}
|
|
|
|
public function view_investors_details($id)
|
|
{
|
|
$currentInvestment = $this->getUserProducts('Holding', $id);
|
|
$reedemedInvestment = $this->getUserProducts('Reedemed', $id);
|
|
|
|
$totalInvestmentForHolding = array_sum(array_column($currentInvestment['productsDetails'], 'total_investment_amount'));
|
|
$totalInvestmentForReedemed = array_sum(array_column($reedemedInvestment['productsDetails'], 'total_investment_amount'));
|
|
|
|
$totalInvestment = $this->IND_money_format($totalInvestmentForHolding + $totalInvestmentForReedemed);
|
|
|
|
// return $reedemedInvestment;
|
|
// echo '<pre>';
|
|
// print_r($currentInvestment);
|
|
// die;
|
|
|
|
$user = User::findOrFail($id);
|
|
|
|
return view('Admin.Pages.manage_investors.view_investors_detail', compact('user', 'currentInvestment', 'totalInvestment', 'reedemedInvestment'));
|
|
}
|
|
|
|
public function getUserProducts($type, $id)
|
|
{
|
|
$user = MonthlyUpdateMaster::where(['users_id' => $id, 'holding_status' => $type])->get();
|
|
$productDetails = [];
|
|
foreach ($user as $singleMUM) {
|
|
$dataArr = [
|
|
'id' => $singleMUM->id,
|
|
'categories' => $singleMUM->categories,
|
|
'product_category' => $singleMUM->product_category,
|
|
'product_name' => $singleMUM->product_name,
|
|
'platform' => Company::find($singleMUM->investment_platform)->value('company_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');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($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');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($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');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($data->getRawOriginal('total_investment'));
|
|
} elseif ($singleMUM->categories == 'Faircent') {
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('all_time_amount_invested');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($data->getRawOriginal('all_time_amount_invested'));
|
|
} elseif ($singleMUM->categories == 'Finance Peer') {
|
|
$dataArr['total_investment_amount'] = $data->getRawOriginal('all_time_investment_added');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($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->getRawOriginal('amount_invested');
|
|
$dataArr['total_investment_amount_in_rs'] = $this->IND_money_format($data->getRawOriginal('amount_invested'));
|
|
array_push($productDetails, $dataArr);
|
|
}
|
|
}
|
|
|
|
$totalInvestment = array_sum(array_column($productDetails, 'total_investment_amount'));
|
|
|
|
$totalInvestment = $this->IND_money_format(($totalInvestment));
|
|
|
|
return [
|
|
'productsDetails' => $productDetails,
|
|
'totalInvestment' => $totalInvestment
|
|
];
|
|
}
|
|
|
|
public function investedProductDetails($id)
|
|
{
|
|
$monthlyUpdateMaster = MonthlyUpdateMaster::findOrFail($id);
|
|
$peerToPeerLending = ['Finance Peer', 'Faircent', 'Liquiloans'];
|
|
$indianfinacial = ['Invoice Discounting', 'Clean And Green Assets', 'Venture Debt', 'High Yield Finance', 'Securitized debt instrument', 'Lease Based Financing', 'Revenue Based Financing'];
|
|
if (in_array($monthlyUpdateMaster->categories, $peerToPeerLending)) {
|
|
$data = MonthlyUpdatePeerToPeerLending::where('custom_id', $monthlyUpdateMaster->custom_id)->latest()->first();
|
|
} elseif ($monthlyUpdateMaster->categories == 'Fractional Real Estate') {
|
|
$data = MonthlyUpdateFractionalRealEstate::where('custom_id', $monthlyUpdateMaster->custom_id)->latest()->first();
|
|
} elseif (in_array($monthlyUpdateMaster->categories, $indianfinacial)) {
|
|
$data = MonthlyUpdateIndianFinancialAssets::where('custom_id', $monthlyUpdateMaster->custom_id)->latest()->first();
|
|
} elseif ($monthlyUpdateMaster->categories == "Alternative Investment Fund") {
|
|
$data = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $monthlyUpdateMaster->custom_id)->latest()->first();
|
|
}
|
|
return view('Admin.Pages.manage_investors.invested_products.index', [
|
|
'monthlyUpdateMaster' => $monthlyUpdateMaster,
|
|
'data' => $data
|
|
]);
|
|
}
|
|
|
|
|
|
function IND_money_format($number)
|
|
{
|
|
$number = (float) $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;
|
|
}
|
|
|
|
public function downloadBankStatement($file_name)
|
|
{
|
|
return \Storage::download('user_cancelled_check_bank_statement/' . $file_name);
|
|
}
|
|
|
|
public function downloadPan($file_name)
|
|
{
|
|
return \Storage::download('user_pan_front/' . $file_name);
|
|
}
|
|
|
|
public function downloadAadhar($file_name)
|
|
{
|
|
return \Storage::download('user_aadhar_card/' . $file_name);
|
|
}
|
|
|
|
public function downloadDocumentFront($file_name)
|
|
{
|
|
return \Storage::download('user_document_front/' . $file_name);
|
|
}
|
|
|
|
public function downloadDocumentBack($file_name)
|
|
{
|
|
return \Storage::download('user_document_back/' . $file_name);
|
|
}
|
|
|
|
public function kycStatus(Request $request)
|
|
{
|
|
$status = UserKyc::where('id', $request->id)->update([
|
|
'status' => $request->status
|
|
]);
|
|
if ($status) {
|
|
$userId = UserKyc::find($request->id);
|
|
$user = User::find($userId->users_id);
|
|
$notify['message'] = "Your KYC has been $request->status!";
|
|
$user->notify(new UserAdmin($notify));
|
|
return response()->json(['status' => 200, 'message' => "Kyc $request->status"]);
|
|
}
|
|
return response()->json(['status' => 400, 'message' => "Kyc could not be $request->status"]);
|
|
}
|
|
|
|
public function dataTableKYC(Request $request)
|
|
{
|
|
if ($request->ajax()) {
|
|
$data = UserKyc::with('user');
|
|
if ($request->dropdownValue == 'Approved' || $request->dropdownValue == 'Rejected' || $request->dropdownValue == 'New') {
|
|
$data->where('status', $request->dropdownValue);
|
|
};
|
|
if ($request->dropdownValue == 'Individual' || $request->dropdownValue == 'HUF' || $request->dropdownValue == 'NRI' || $request->dropdownValue == 'Company' || $request->dropdownValue == 'Partnership' || $request->dropdownValue == 'Others') {
|
|
$data->where('kyc_type', $request->dropdownValue);
|
|
};
|
|
$data->orderBy('updated_at','desc')->select('*');
|
|
return Datatables::of($data)->addIndexColumn()
|
|
// return Datatables::of($data)
|
|
->editColumn('created_at', function ($row) {
|
|
$formattedDate = $row->updated_at->format('d/m/Y');
|
|
return '<div class="badge badge-light fw-bold">' . $formattedDate . '</div>';
|
|
})
|
|
->editColumn('name', function ($row) {
|
|
return '<div>' . $row->user->name . '</div>';
|
|
})
|
|
->editColumn('email', function ($row) {
|
|
return '<div>' . $row->email . '</div>';
|
|
})
|
|
->editColumn('status', function ($row) {
|
|
return '<div>' . $row->status . '</div>';
|
|
})
|
|
->addColumn('action', function ($row) {
|
|
if ($row->status == 'Approved') {
|
|
$btn = '<a href="' . route("manage_investor_view", $row->id) . '" class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Detail">
|
|
<i class="fa-regular fa-eye"></i>
|
|
</a>
|
|
<a href="' . route("view_investors_details", $row->users_id) . '" onclick=returnRedirect("manage_investor_kyc") class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Invetsor Profile">
|
|
<i class="fa-solid fa-user"></i>
|
|
</a>
|
|
<a class="action_icon" data-bs-toggle="tooltip" onclick="kycRejectStatus(' . $row->id . ')" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="Rejected">
|
|
<i class="fa-solid fa-square-xmark"></i>
|
|
</a>
|
|
';
|
|
} elseif ($row->status == "Rejected") {
|
|
$btn = '<a href="' . route("manage_investor_view", $row->id) . '" class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Detail">
|
|
<i class="fa-regular fa-eye"></i>
|
|
</a>
|
|
<a href="' . route("view_investors_details", $row->users_id) . '" onclick=returnRedirect("manage_investor_kyc") class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Invetsor Profile">
|
|
<i class="fa-solid fa-user"></i>
|
|
</a>
|
|
<a class="action_icon" data-bs-toggle="tooltip" onclick="kycApproveStatus(' . $row->id . ')" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="Approved">
|
|
<i class="fa-solid fa-square-check"></i>
|
|
</a>
|
|
<a class="action_icon send-mail reply_mail" onclick="hello(\'' . $row->email . '\')" data-email="he" data-subject="he" data-contact-us-id="he" title="Reply">
|
|
<svg class="svg-inline--fa fa-reply" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="reply" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M205 34.8c11.5 5.1 19 16.6 19 29.2v64H336c97.2 0 176 78.8 176 176c0 113.3-81.5 163.9-100.2 174.1c-2.5 1.4-5.3 1.9-8.1 1.9c-10.9 0-19.7-8.9-19.7-19.7c0-7.5 4.3-14.4 9.8-19.5c9.4-8.8 22.2-26.4 22.2-56.7c0-53-43-96-96-96H224v64c0 12.6-7.4 24.1-19 29.2s-25 3-34.4-5.4l-160-144C3.9 225.7 0 217.1 0 208s3.9-17.7 10.6-23.8l160-144c9.4-8.5 22.9-10.6 34.4-5.4z"></path></svg><!-- <i class="fa-solid fa-reply"></i> Font Awesome fontawesome.com -->
|
|
</a>
|
|
';
|
|
} else {
|
|
$btn = '<a href="' . route("manage_investor_view", $row->id) . '" class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Detail">
|
|
<i class="fa-regular fa-eye"></i>
|
|
</a>
|
|
<a href="' . route("view_investors_details", $row->users_id) . '" onclick=returnRedirect("manage_investor_kyc") class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Invetsor Profile">
|
|
<i class="fa-solid fa-user"></i>
|
|
</a>
|
|
<a class="action_icon" data-bs-toggle="tooltip" onclick="kycApproveStatus(' . $row->id . ')" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="Approved">
|
|
<i class="fa-solid fa-square-check"></i>
|
|
</a>
|
|
<a class="action_icon" data-bs-toggle="tooltip" onclick="kycRejectStatus(' . $row->id . ')" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="Rejected">
|
|
<i class="fa-solid fa-square-xmark"></i>
|
|
</a>
|
|
';
|
|
}
|
|
return $btn;
|
|
})
|
|
->rawColumns(['name', 'email', 'created_at', 'status', 'action'])
|
|
->make(true);
|
|
}
|
|
|
|
return view('Admin.Pages.manage_investors.manage_investor_kyc');
|
|
}
|
|
|
|
public function downloadFile(Request $request)
|
|
{
|
|
if (\Storage::exists($request->file)) {
|
|
return Storage::download($request->file);
|
|
} else {
|
|
return "File not found";
|
|
}
|
|
}
|
|
|
|
public function manageInvestorDataTableKYC(Request $request)
|
|
{
|
|
if ($request->ajax()) {
|
|
$data = User::query();
|
|
// print_r($request->dropdownValue);
|
|
$data->users();
|
|
if ($request->dropdownValue == '1' || $request->dropdownValue == '0') {
|
|
$data->where('status', $request->dropdownValue);
|
|
};
|
|
if ($request->dropdownValue === 'Zero') {
|
|
$data->doesntHave('investments');
|
|
}
|
|
// if ($request->dropdownValue == 'Individual' || $request->dropdownValue == 'HUF' || $request->dropdownValue == 'NRI' || $request->dropdownValue == 'Company' || $request->dropdownValue == 'Partnership' || $request->dropdownValue == 'Others') {
|
|
// $data->where('kyc_type', $request->dropdownValue);
|
|
// };
|
|
$data->latest()->select('*');
|
|
$count = 1;
|
|
return Datatables::of($data)->addIndexColumn()
|
|
// return Datatables::of($data)
|
|
->editColumn('created_at', function ($row) {
|
|
$formattedDate = $row->created_at->format('d/m/Y');
|
|
return '<div class="badge badge-light fw-bold">' . $formattedDate . '</div>';
|
|
})
|
|
->editColumn('name', function ($row) {
|
|
return '<div>' . $row->name . '</div>';
|
|
})
|
|
->editColumn('email', function ($row) {
|
|
return '<div>' . $row->email . '</div>';
|
|
})
|
|
->editColumn('contact_number', function ($row) {
|
|
return '<div>' . $row->contact_number . '</div>';
|
|
})
|
|
->editColumn('amount_invested', function ($row) {
|
|
return '<div>' . $this->totalInvestment($row->id) . '</div>';
|
|
})
|
|
->editColumn('active_investment', function ($row) {
|
|
return '<div>' . $this->totalInvestmentCount($row->id) . ' Investment(s)</div>';
|
|
})
|
|
->editColumn('status', function ($row) {
|
|
return '<div>' . $row->status . '</div>';
|
|
})
|
|
->addColumn('action', function ($row) {
|
|
$checked = $row->status == 1 ? 'checked' : '';
|
|
$btn = '<div class="text-end d-flex align-items-center justify-content-around"><a href="' . route("view_investors_details", $row->id) . ' class="action_icon" data-bs-toggle="tooltip" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="View Detail">
|
|
<i class="fa-regular fa-eye"></i>
|
|
</a>
|
|
<a class="action_icon" data-bs-toggle="tooltip" data-count="" onclick="status(' . $row->id . ',' . $row->status . ',' . $row->id . ')" data-bs-custom-class="tooltip-inverse" data-bs-placement="top" title="Active and Inactive">
|
|
<label class="form-check form-switch form-switch-sm form-check-custom form-check-solid flex-stack" style="text-align:center !important; display:block">
|
|
<input class="form-check-input status' . $row->id . '" type="checkbox" ' . $checked . ' value="' . $row->status . '" />
|
|
</label>
|
|
</a></div>';
|
|
return $btn;
|
|
})
|
|
->rawColumns(['name', 'email', 'contact_number', 'amount_invested', 'active_investment', 'created_at', 'status', 'action'])
|
|
->make(true);
|
|
}
|
|
|
|
return view('Admin.Pages.manage_investors.manage_investors');
|
|
}
|
|
|
|
public function totalInvestmentCount($id)
|
|
{
|
|
return MonthlyUpdateMaster::where(['users_id' => $id, 'holding_status' => 'Holding'])->count();
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
}
|