limit laravel
$posts = Post::all()->limit(10)->get();
laravel join
Inner Join : ->join('contacts', 'users.id', '=', 'contacts.user_id')
Left Join : ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
Right Join : ->rightJoin('posts', 'users.id', '=', 'posts.user_id')
Cross Join : ->crossJoin('colors')
Advance Queries :
-----------------
->join('contacts', function ($join) {
$join->on('users.id', '=', 'contacts.user_id')
->where('contacts.user_id', '>', 5);
})
laravel join
$latestPosts = DB::table('posts')
->select('user_id', DB::raw('MAX(created_at) as last_post_created_at'))
->where('is_published', true)
->groupBy('user_id');
$users = DB::table('users')
->joinSub($latestPosts, 'latest_posts', function ($join) {
$join->on('users.id', '=', 'latest_posts.user_id');
})->get();
laravel where
$users = DB::table('users')
->whereDate('created_at', '2016-12-31')
->get();
laravel where
$users = DB::table('users')
->whereMonth('created_at', '12')
->get();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us