method() == 'post') { (new Admin_Location([ 'id_admin' => $driver->id_admin, 'date' => date('Y-m-d H:i:s'), 'lat' => $this->request()['lat'], 'lon' => $this->request()['lon'], 'accuracy' => $this->request()['accuracy'] ]))->save(); } if ($driver->location()->id_admin_location) { echo $driver->location()->json(); } else { echo json_encode(null); } break; default: if ($this->method() == 'post') { // save a setting } echo $driver->json(); break; } } }