From 49598c32db4095a983d22b48366e53cb8dfecee5 Mon Sep 17 00:00:00 2001 From: Ritikesh yadav Date: Fri, 21 Jun 2024 12:43:25 +0530 Subject: [PATCH] added log and exceptions --- .../Frontend/DashboardController.php | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php index e4072ff..a365586 100644 --- a/app/Http/Controllers/Frontend/DashboardController.php +++ b/app/Http/Controllers/Frontend/DashboardController.php @@ -29,6 +29,7 @@ use Cviebrock\EloquentSluggable\Services\SlugService; use Illuminate\Support\Facades\Session; use DB; +use Illuminate\Support\Facades\Log; class DashboardController extends Controller { public function index() @@ -65,29 +66,35 @@ class DashboardController extends Controller 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) + try{ + $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; + }catch(\Exception $e) { - $data['data'] = $sellerData; - return $data; + Log::error("Something went wrong while fetching aif sold investment - ". $e->getMessage() . " on ". $e->getLine()) + // Log::error("Something went wrong while investment-". $e->getMessage() ." " .$e->getLine()); } - if(count($sellerData->toArray())) - { - $market_place_data = $sellerData[0]->aif->toArray(); - // dd($market_place_data); - return $market_place_data; - } - return $sellerData; } @@ -187,14 +194,20 @@ class DashboardController extends Controller 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, - ]; + try{ + + $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, + ]; + }catch(\Exception $e) + { + Log::error("Something went wrong while investment-". $e->getMessage() ." " .$e->getLine()); + } } public function investmentSummary()