addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { if (is_array($this->routes) && !empty($this->routes)) { $this->routes = kg_json_encode($this->routes); } else { $this->routes = ''; } $this->create_time = time(); } public function beforeUpdate() { if (is_array($this->routes) && !empty($this->routes)) { $this->routes = kg_json_encode($this->routes); } $this->update_time = time(); } public function afterFetch() { if (is_string($this->routes) && !empty($this->routes)) { $this->routes = json_decode($this->routes, true); } } public static function types() { return [ self::TYPE_SYSTEM => '内置', self::TYPE_CUSTOM => '自定', ]; } public static function sysRoleTypes() { return [ self::ROLE_ROOT => '管理人员', self::ROLE_OPERATOR => '运营人员', self::ROLE_EDITOR => '编辑人员', self::ROLE_FINANCE => '财务人员', ]; } }