public function value($parent_field = false) { if ($parent_field) { $value = (new Query())->select([[DB::expr('MAX(' . $this->_field . ')'), $this->_field]])->from($this->_model->get_table())->where($parent_field, '=', $this->_model->get($parent_field))->one(); if ($value) { $value = $value[$this->_field] ?: 0; } } else { $value = (new Query())->select([[DB::expr('MAX(' . $this->_field . ')'), $this->_field]])->from($this->_model->get_table())->one(); if ($value) { $value = $value[$this->_field] ?: 0; } } return $value + 1; }
/** * Returns the ids of available roles. * * @param array $role * @return array */ public function get_role_ids(array $role) { return ORM::factory('Role')->load(DB::query('id')->where('name', 'IN', $role))->as_array(); }
public function value() { return Text::to_slug($this->_model->get($this->_field)); }