/** * The functions to load invitations page * * @return string */ public function index() { try { //Get the invitations for the currently logged in user $invitations = $this->userRepo->paginateInvitations($this->auth->user()); //Get next Page url $nextPageUrl = generate_next_page_url($invitations); //This is not an ajax request if (!$this->input->is_ajax_request()) { //Load view with data $this->load->view('pages/invitations', compact('invitations', 'nextPageUrl')); } else { //Is an ajax request echo json_encode(['error' => false, 'grid' => $this->load->view('pages/partials/_invitations-grid', compact('invitations'), true), 'nextPageUrl' => $nextPageUrl]); } } catch (Exception $e) { //Unexpected error //This is not an ajax request if (!$this->input->is_ajax_request()) { //Show error page show_404(); } else { //Is an ajax request echo json_encode(['error' => true, 'message' => $e->getMessage()]); } } }