function get_logged_company() { if (!$this->is_signed_in()) { return NULL; } else { if ($this->CI->session->userdata('company_id') || $this->CI->session->userdata('institution_id')) { $c = new Company(); $c->where('id', $this->CI->session->userdata('company_id'))->get(); if ($c->exists()) { return $c; } else { $c = new Institution(); $c->where('id', $this->CI->session->userdata('institution_id'))->get(); if ($c->exists()) { return $c; } } } return NULL; } }