/** * Save * * @return mixed */ public function save() { if ($this->is_new()) { $this->created_at = Time::now(); } else { $this->modified_at = Time::now(); } return parent::save(); }
public function save(array $options = array()) { if (empty($this->id)) { $max_sort = DB::table($this->table)->where('parent', !empty($this->parent) ? $this->parent : 0)->where('deleted_at', null)->max('sort'); $this->sort = is_numeric($max_sort) ? $max_sort + 1 : 0; } if (!empty($this->element_id)) { if (empty($this->module)) { $this->element_id = 0; } else { $module = 'Model\\' . ucfirst($this->module); $element = $module::find($this->element_id); if (!empty($element->id)) { $this->path = $element->path; } } } return parent::save($options); }