framework icon indicating copy to clipboard operation
framework copied to clipboard

ThinkPHP Framework

Results 260 framework issues
Sort by recently updated
recently updated
newest added

场景如下: 我在后台管理项目中有一个【权限校验中间件】 应用中间件设置了该中间件, 做了全局的权限校验 控制器中间件,我想取消该中间件的执行,登录接口不需要做权限校验 我不想在中间件中硬编码,指定放行的路由,想在控制器中单独取消该权限校验的中间件,请问如何操作呢?

``` protected $rule = [ 'id' => 'require|integer', 'age' => 'require|integer', ]; protected $scene = [ 'add' => [ 'id', 'age' ], ]; ``` 如上是我一开始的验证器代码,我希望验证场景是add的时候去验证id和age这两个参数。 后面app跟我反馈,id和age是非必填的,我想到的肯定是在验证场景里面把这两个参数去掉 ``` protected $rule =...

验证器能否增加一个`获取字段`的方法,比如说`getFields()`; 比如下面这段代码中,我可以直接使用验证器的字段名,来过滤提交的信息,而不须要单独写一个过滤数组; ``` $validate = Validate::rule('nickname|昵称', ValidateRule::isRequire()->length('1,20')) ->rule('avatar|头像', ValidateRule::isRequire()) ->rule('sex|性别', ValidateRule::isRequire()->in([0, 1, 2])); $save_name = [ 'nickname', 'avatar', 'sex', ]; // $save_name = $validate->getFields(); $post_data = $request->only($save_name,'POST'); ```

enhancement
Validate

是这样循环批处理的 ![image](https://user-images.githubusercontent.com/5431843/133638850-9fb29e78-c4b2-4d80-83dd-69ba828387cb.png) 用的方法都是DB:table这个方法 我看了model的saveall的源码 ![image](https://user-images.githubusercontent.com/5431843/133639104-ba400cbd-c023-4ae9-80be-e4ae97c042c7.png) 也是一条一条更新的 请问这种场景,要怎么解决呢? 没有办法公用一个数据库链接吗?

select * from table where name = 'knoW'; -- 可以查到 name = know / KNOW /KnoW的, select * from table where binary name = 'kNoW'; -- 只能查到 name = kNoW的。...

``` $data = [ 'id' => 0, 'user_name' => '老王' ]; // 使用静态模型类调用 create 方法 $user = UserModel::create($data); // 获取新增的自增ID是0,不是新增主键 ID 的值 $uid = $user->id; // 0 halt($user->toArray()); // 显示与我上面的...

``` var_dump($this->request->request()); var_dump($this->request->post());die; ``` ![image](https://user-images.githubusercontent.com/43992249/130935341-c77db4a0-b947-4f45-ab4c-923b76c84a7c.png) 个人比较喜欢用request接收参数,我认为request是包含了post和get参数的,参考[`PHP` 官方网站](https://www.php.net/manual/zh/reserved.variables.request.php) 请问为什么通过request获取不到而post可以呢? 参考了[tp文档](https://www.kancloud.cn/manual/thinkphp6_0/1037519)

多应用模式下path默认没有按应用区分 手册里写了 默认是区分应用的

根据下图手册的写法,会报错 `not support data:district_id=1`,是本菜使用姿势不对,还是bug了? ``` class Community extends Validate { protected $rule = [ 'district_id|所属区域' => 'require', 'name' => 'unique:system_community,district_id=1', ]; } ``` ![image](https://user-images.githubusercontent.com/20442232/129653507-7c702fce-a9de-41c0-a4cc-4199e3871cdc.png)

bug
Validate

vendor\topthink\framework\src\think\Request.php:979 function post()... 当前端config字段传空值,后端使用以下代码时, $postConfig = $this->request->post('config/a', []); $postConfig预期得到空值,但实际得到并非为空数组,而是有一个值为空字符串的数组,[""]。 而这个值在if ($postConfig) 会返回false.