public function update($id) { $this->data['entry'] = Jobs::findOne($id); if ($this->request->isPost() || $this->request->isPut()) { try { $post = $this->request->post(); $post = Filter::fromSchema($this->schema())->run($post); Jobs::update($id, $post); h('notification.info', 'Job updated.'); } catch (\Exception $e) { h('notification.error', $e); } } }
/** * Filter model data with functions to cleanse, prepare and validate data. When key argument specified, filter will run partially for specified key only. * * @param \Norm\Model $model * * @param string $key Key field of model * * @return bool True if success and false if fail */ public function filter(Model $model, $key = null) { if (is_null($this->filter)) { $this->filter = Filter::fromSchema($this->schema()); } $this->applyHook('filtering', $model, $key); $result = $this->filter->run($model, $key); $this->applyHook('filtered', $model, $key); return $result; }