request_model = $this->load->model('request'); } public function get_data(): ?array { $uid = $this->request_model->get_int('id', FALSE); if ($uid === FALSE) { if ($this->main->session) { $uid = $this->main->user()['id']; } else { return NULL; } } $user = $this->db ->select('*') ->from('api.user u') ->where('u.id') ->eq($uid) ->row(); if (!$user) { return NULL; } $following = FALSE; $followed = FALSE; $follow_id = NULL; if ($this->main->session) { $sid = $this->main->user()['id']; $res = $this->db->select('f.value, f.id') ->from('admin.follow f') ->where('f.follower_id') ->eq($sid) ->where('f.followee_id') ->eq($uid) ->row(); $following = $res ? $res['value'] : FALSE; $follow_id = $res ? $res['id'] : NULL; $res = $this->db->select('f.value') ->from('admin.follow f') ->where('f.follower_id') ->eq($uid) ->where('f.followee_id') ->eq($sid) ->row(); $followed = $res ? $res['value'] : FALSE; } $data = parent::get_data(); $data['user'] = $user; $data['following'] = $following; $data['followed'] = $followed; $data['follow_id'] = $follow_id; $data['title'] = ucfirst(lang('title', sub: [$user['first_name']])); return $data; } }