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