コード例 #1
0
 public function dashboard($idget = null)
 {
     $user_info = Auth::user();
     $totalNotesPending = 0;
     $Receiver = $user_info->id;
     $ReceiverDetail = User::find($Receiver);
     $MeetingRequestPending = $ReceiverDetail->Giver()->Where('status', '=', 'pending')->count();
     //echo $MeetingRequestPending;exit;
     // Calculate number of connection user have on KC platform
     //echo $MeetingRequestPending;
     $user_id = 0;
     $location = '';
     if (!empty($user_info)) {
         $user_id = $user_info->id;
         $location = $user_info->location;
     }
     /*Dashboard section*/
     // fetch user connections on KC
     $getUserConnection = KarmaHelper::getUserConnection($user_id, $location);
     $user_connection_onkc = 0;
     if (!empty($getUserConnection)) {
         foreach ($getUserConnection as $key => $value) {
             if (isset($value->con_user_id)) {
                 $user_connection_onkc++;
             }
         }
     }
     // fetch pending karmanote requests
     $PendingRequest = array();
     $totalPendingRequest = 0;
     $PendingRequest = KarmaHelper::getPendingKarmaNotes($user_info->id);
     if (!empty($PendingRequest)) {
         $totalPendingRequest = count($PendingRequest);
     }
     //fetch pending KM requests only received no read no unread
     $totalReceivedRequest = 0;
     $GiverInMeeting = Auth::User()->Giver()->where('status', 'pending')->orderBy('updated_at', 'DESC')->get();
     if (!empty($GiverInMeeting)) {
         $totalReceivedRequest = count($GiverInMeeting);
     }
     //fetch pending karma intros
     $totalintroductionInitiated = 0;
     $IntroducerInitiated = Auth::User()->Introducer;
     if (!empty($IntroducerInitiated)) {
         foreach ($IntroducerInitiated as $key => $value) {
             if (!empty($value['user_id_receiver'])) {
                 $value['user_id_receiver'] = User::find($value['user_id_receiver'])->toArray();
             }
             if (!empty($value['user_id_giver'])) {
                 $value['user_id_giver'] = User::find($value['user_id_giver'])->toArray();
             } else {
                 $value['user_id_giver'] = Connection::find($value['connection_id_giver'])->toArray();
             }
             if ($value->status == 'pending') {
                 $totalintroductionInitiated++;
             }
         }
     }
     // fetch queries that have been posted in the last 7 days within common groups including both public & private.
     $Usergroup = KarmaHelper::getuserGroup();
     $All_groups = '';
     $group_question = 0;
     $totagroupquestion = 0;
     $yesterday = Carbon::now()->subDays(1);
     $one_week_ago = Carbon::now()->subWeeks(1);
     $group_question = DB::table('questions')->select(array('*'))->where('questions.user_id', '!=', $user_info->id)->where('questions.queryStatus', 'open')->where('questions.created_at', '>=', $one_week_ago)->where('questions.created_at', '<=', $yesterday)->orderBy('questions.created_at', 'DESC')->groupBy('id')->get();
     if (!empty($group_question)) {
         $totagroupquestion = count($group_question);
     }
     // fetch a 3 random users on KC platform with a common group of logged in user
     $getKcuser = array();
     $getKcuser = KarmaHelper::getKcuser(0);
     if (empty($getKcuser)) {
         // fetch a user connection either KC or NON KC
         $getsuggestion = KarmaHelper::getUserConnection($user_id, $location);
         //get test users id
         $getUser = KarmaHelper::getTestUsers();
         if (!empty($getsuggestion)) {
             foreach ($getsuggestion as $key => $value) {
                 $test_match = in_array($value->con_user_id, $getUser);
                 if ($value->con_user_id != "" && $test_match != 1) {
                     $getKc = DB::table('users as u')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.id', '=', $value->con_user_id)->where('u.userstatus', '=', 'approved')->get();
                     if (!empty($getKc)) {
                         $value->networkid = $getKc;
                     }
                 }
             }
             $getsuggestion = $getsuggestion[array_rand($getsuggestion)];
         }
         // fetch a user connection only nON kc
         $getinvites = "";
         $getinvites = KarmaHelper::getUserNonKcConnection($user_id, $location);
         if (!empty($getinvites)) {
             $getinvites = $getinvites[array_rand($getinvites)];
         }
     }
     $checkMeetingStatus = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[0]->id);
     $checkMeetingStatusOne = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[1]->id);
     $checkMeetingStatusTwo = KarmaHelper::getMeetingStatusForWeb($user_id, $getKcuser[2]->id);
     //fetch random 5 unique notes
     $getKarmanote = "";
     $getKarmanote = KarmaHelper::getKarmanote();
     foreach ($getKcuser as $key => $value) {
         $giver_id = $value->id;
         $MeetingRequestPending = KarmaHelper::karmaMeetingPendingCount($Receiver, $giver_id);
         $MeetingRequestPendingArray[] = $MeetingRequestPending;
     }
     return View::make('dashboard', array('pageTitle' => 'Dashboard | Karmacircles', 'pageDescription' => 'KarmaCircles is an online peer-to-peer knowledge sharing platform.', 'MeetingRequestPending' => $MeetingRequestPendingArray[0], 'MeetingRequestPendingOne' => $MeetingRequestPendingArray[1], 'MeetingRequestPendingTwo' => $MeetingRequestPendingArray[2], 'totagroupquestion' => $totagroupquestion, 'getKarmanote' => $getKarmanote, 'getKcuserTwo' => $getKcuser[2], 'getKcuserOne' => $getKcuser[1], 'getKcuser' => $getKcuser[0], 'checkMeetingStatus' => $checkMeetingStatus, 'checkMeetingStatusOne' => $checkMeetingStatusOne, 'checkMeetingStatusTwo' => $checkMeetingStatusTwo, 'totalintroductionInitiated' => $totalintroductionInitiated, 'totalReceivedRequest' => $totalReceivedRequest, 'totalPendingRequest' => $totalPendingRequest, 'user_connection_onkc' => $user_connection_onkc, 'CurrentUser' => $user_info, 'PendingMeetingRequest' => $MeetingRequestPending, 'NotesPendingRequest' => $totalNotesPending));
 }