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