public function get_index() { $data = Movies::all(); $result = array(); foreach ($data as $v) { $result[] = $v->to_array(); } $json = json_encode($result); return $json; }