-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] app/Repository/IRepository.php中findByField和findByFilter方法无效 #546
Comments
Hey @cxszn! I'm here to help you with your software development issues. Let's work together to solve the bug you've encountered.
public function handleSearch(Builder $query, array $params): Builder
{
return $query
->when(Arr::get($params, 'username'), static function (Builder $query, $username) {
$query->where('username', $username);
})
->when(Arr::get($params, 'method'), static function (Builder $query, $method) {
$query->where('method', $method);
})
->when(Arr::get($params, 'router'), static function (Builder $query, $router) {
$query->where('router', $router);
})
->when(Arr::get($params, 'service_name'), static function (Builder $query, $service_name) {
$query->where('service_name', $service_name);
})
->when(Arr::get($params, 'ip'), static function (Builder $query, $ip) {
$query->where('ip', $ip);
})
->when(Arr::get($params, 'created_at'), static function (Builder $query, $created_at) {
$query->whereBetween('created_at', $created_at);
})
->when(Arr::get($params, 'updated_at'), static function (Builder $query, $updated_at) {
$query->whereBetween('updated_at', $updated_at);
});
} 确保 To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Repository->handlerSearch 有处理 type 吗? |
findByFilter 语义是有点不太对,按照你的理解应该是等同于 model::where($where)->first 但是实际则是需要在 handleSearch 方法里面对 type 进行一次处理才行 |
执行命令并粘贴以下结果。
Command:
uname -a && php -v && composer info | grep mine && php --ri swoole
# Paste the result here.
bug描述:
重现步骤:
findByFilter(['type' => 'sdgds']);例如这个随便输入数据库的字段也会调用显示数据库排序靠前的第一条数据
这个逻辑和方法名不一样findByField
拉取的版本为20250217最新测试发现
The text was updated successfully, but these errors were encountered: