'查看', 'add' => '添加', 'edit' => '编辑', 'del' => '删除', 'sort' => '排序', 'modify' => '属性设置', ]; } /** * 自从生成常规操作权限 * * @param int $id * @param string $name * @param string $path * @throws Exception */ public static function generate(int $id, string $name, string $path) { $actions = self::defaultAction(); $delete = []; $insert = []; $created = date('Y-m-d H:i:s'); foreach ($actions as $key => $action) { $name = explode(':', $name)[0]; $delete[] = $name.':'.$key; $arr = []; $arr['title'] = $action; $arr['pid'] = $id; $arr['name'] = $name.':'.$key; $arr['type'] = self::TYPE_ACTION; $arr['path'] = $path.$id.','; $arr['remark'] = sprintf("自动生成[%s][%s]操作", $name, $action); $arr['created_at'] = $created; $insert[] = $arr; } //删除已有常规操作 self::where('pid', $id)->whereIn('name', $delete)->delete(); //新增常规操作 (new self())->saveAll($insert); } }