public static function sandbox() { // Testaa koodiasi täällä //$catch_1 = CatchModel::find(1); $catch = new CatchModel(array('kalalaji' => "lahna", 'lkm' => '0', 'vedenLampo' => '-3')); $errors = $catch->errors(); Kint::dump($errors); }
public static function store() { self::check_logged_in(); $params = $_POST; $attributes = array('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']; } //Kint::dump($attributes); $catch = new CatchModel($attributes); $errors = $catch->errors(); //Kint::dump($errors); if (count($errors) === 0) { $catch->save(); //Kint::dump($catch->catch_id); Redirect::to("/catchList/" . $catch->catch_id . "", array('message' => 'Saalistieto lisättiin onnistuneesti!')); } else { $traps = Trap::in_use(); $trap_types = Trap::types(); View::make('catch/newCatch.html', array('errors' => $errors, 'attributes' => $attributes, 'traps' => $traps, 'trap_types' => $trap_types, 'friend_of' => $_SESSION['friend_of'])); } }