public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('catch_id' => $id, 'date' => $params['date'], 'time' => $params['time'], 'species' => $params['species'], 'count' => $params['count'], 'length' => $params['length'], 'weight' => $params['weight'], 'water_sys' => $params['water_sys'], 'location' => $params['location'], 'wind_speed' => $params['wind_speed'], 'wind_dir' => $params['wind_dir'], 'air_temp' => $params['air_temp'], 'water_temp' => $params['water_temp'], 'cloudiness' => $params['cloudiness'], 'notes' => $params['notes'], 'picture_url' => $params['picture_url'], 'trap_type' => $params['trap_type'], 'trap_id' => $params['trap_model']); if (isset($params['friends'])) { $attributes['friends'] = $params['friends']; } $catch = new CatchModel($attributes); $errors = $catch->errors(); if (count($errors) === 0) { $catch->update(); Redirect::to('/catchList/' . $catch->catch_id . '', array('message' => "Saalistieto päivitettiin onnistuneesti!")); } else { $catchers = CatchModel::catchers($catch->catch_id); $catch->friends = $catchers; View::make('catch/updateCatch.html', array('attributes' => $attributes, 'errors' => $errors)); } }