1$affected = DB::table('users')
2 ->where('id', 1)
3 ->update(['votes' => 1]);
1$latestPosts = DB::table('posts')
2 ->select('user_id', DB::raw('MAX(created_at) as last_post_created_at'))
3 ->where('is_published', true)
4 ->groupBy('user_id');
5
6$users = DB::table('users')
7 ->joinSub($latestPosts, 'latest_posts', function ($join) {
8 $join->on('users.id', '=', 'latest_posts.user_id');
9 })->get();
1$users = DB::table('users')
2 ->whereDate('created_at', '2016-12-31')
3 ->get();