bigbug-gg 3年前

修改理由:

修改注释

详细描述:

注释和代码内容不匹配

相关信息:


此投稿已在 3年前 合并。

标题修改:

+ 模型关联

内容修改:

红色背景 为原始内容

绿色背景 为新增或者修改的内容

OldNewDifferences
10881088
10891089   use Illuminate\Database\Eloquent\Builder;
10901090
1091    // 获取至少带有一条评论内容包含 foo% 关键词的文章...
 1091   // 获取至少带有一条评论内容包含 code% 关键词的文章...
10921092   $posts = Post::whereHas('comments', function (Builder $query) {
10931093       $query->where('content', 'like', 'code%');
10941094   })->get();
10951095
1096    // 获取至少带有十条评论内容包含 foo% 关键词的文章...
 1096   // 获取至少带有十条评论内容包含 code% 关键词的文章...
10971097   $posts = Post::whereHas('comments', function (Builder $query) {
10981098       $query->where('content', 'like', 'code%');
10991099   }, '>=', 10)->get();
 
11371137   use App\Models\Video;
11381138   use Illuminate\Database\Eloquent\Builder;
11391139
1140    // 查询与帖子或视频相关并且标题包含 foo 的评论...
 1140   // 查询与帖子或视频相关并且标题包含 code 的评论...
11411141   $comments = Comment::whereHasMorph(
11421142       'commentable',
11431143       [Post::class, Video::class],
 
11461146       }
11471147   )->get();
11481148
1149    // 查询与帖子相关的评论,标题不包含 foo%...
 1149   // 查询与帖子相关的评论,标题不包含 code%...
11501150   $comments = Comment::whereDoesntHaveMorph(
11511151       'commentable',
11521152       Post::class,