attributes = $attr; } foreach($allowProp as $prop) { if (isset($attr[$prop])) { $this->attributes[$prop] = $attr[$prop]; } } return $this; } public function insert() { $model = new AppNews(); $model->setRawAttributes($this->attributes); $model->save(); } public function update() { $model = AppNews::find($this->attributes['id']); $model->title = $this->attributes['title']; $model->keywords = $this->attributes['keywords']; $model->description = $this->attributes['description']; $model->cover = $this->attributes['cover']; $model->content = $this->attributes['content']; $model->platform = $this->attributes['platform']; $model->save(); } }