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(); } } }
/** * Persist this collection in the database * @param Jam_Model $model */ public function model_after_delete(Jam_Model $model) { $path = $model->children_path(); Jam::update($model)->where('path', 'LIKE', $path . '%')->update_children($path, '')->execute(); }
public function model_call_decendents(Jam_Model $model, Jam_event_data $data) { $path = $model->children_path(); $data->return = Jam::all($model)->where('path', 'LIKE', "{$path}%"); }