public function getUserById($userId)
 {
     $result = Instagram_user::whereId($userId)->first();
     //first() function in sql returns the first value of the selected column
     return $result;
 }
 public function autolikesSelectAction(Request $request)
 {
     if ($request->isMethod('post')) {
         $insUserId = $request->input('id');
         //            dd($insUserId);
         $action = $request->input('action');
         $objModelInstagramUsers = Instagram_user::getInstance();
         $msg = [];
         $whereIn = implode(',', array_unique($insUserId));
         switch ($action) {
             case 1:
                 //Restart Daily Counter
                 $updated = $objModelInstagramUsers->updateInstagramUserWhere(['daily_post_done' => 0, 'firstpost_delivery_daytime' => 0], ['rawQuery' => 'ins_user_id IN(' . $whereIn . ')']);
                 if ($updated) {
                     echo json_encode(['status' => 200, 'message' => 'Done! We have reset the daily post done count!!']);
                 } else {
                     echo json_encode(['status' => 400, 'message' => 'Some problem occurred. Daily post done may have already reset OR there will not be any post done for today']);
                 }
                 break;
             case 2:
                 // Restart Total Counter
                 $updated = $objModelInstagramUsers->updateInstagramUserWhere(['pics_fetch_count' => 0, 'pics_done' => 0, 'daily_post_done' => 0, 'reset_counter_time' => time()], ['rawQuery' => 'ins_user_id IN(' . $whereIn . ')']);
                 if ($updated) {
                     echo json_encode(['status' => 200, 'message' => 'Done! We have reset the total counter. The profile has restarted again with 0 pics done!!']);
                 } else {
                     echo json_encode(['status' => 400, 'message' => 'Some problem occurred. Please reload the page and try again later.']);
                 }
                 break;
             case 3:
                 //change Server
                 $planId = $request->input('planId');
                 $updated = $objModelInstagramUsers->updateInstagramUserWhere(['plan_id' => $planId], ['rawQuery' => 'ins_user_id IN(' . $whereIn . ')']);
                 if ($updated) {
                     echo json_encode(['status' => 200, 'message' => 'Done! Services has been changed successfully']);
                 } else {
                     echo json_encode(['status' => 400, 'message' => 'Some problem occurred. This may be due to the same se']);
                 }
                 break;
             case 5:
                 //Remove from the system
                 $deleted = $objModelInstagramUsers->deleteInstagramUserWhere(['rawQuery' => 'ins_user_id IN(' . $whereIn . ')']);
                 if ($deleted) {
                     echo json_encode(['status' => 200, 'message' => 'Instagram Profile has been successfully deleted from our system!']);
                 } else {
                     echo json_encode(['status' => 400, 'message' => 'Some problem occurred. Please reload the page and try again.']);
                 }
             default:
                 break;
         }
     }
 }