public function model_call_change_upload_server(Jam_Model $model, Jam_Event_Data $data, $name, $server) { if ($this->_name == $name) { if ($old_server = $model->{$this->_dynamic_server} and $old_server !== $server) { $model->{$this->_name}->move_to_server($server); $model->update_fields($this->_dynamic_server, $server); } } }
public function model_after_save(Jam_Model $model, Jam_Event_Data $data, $changed) { if ($value = Arr::get($changed, $this->name)) { if ($item = $model->{$this->name}) { $old_path = $model->children_path(); $model->update_fields('path', $item->children_path()); $new_path = $model->children_path(); Jam::update($model)->where('path', 'LIKE', $old_path . '%')->update_children($old_path, $new_path)->execute(); } } }
public function model_call_switch_position_with(Jam_Model $model, Jam_Event_Data $data, Jam_Model $switch_with) { $current_position = $model->{$this->_field}; $model->update_fields($this->_field, $switch_with->{$this->_field}); $switch_with->update_fields($this->_field, $current_position); }