“join in laravel” Coderfunda Code Answer’s
laravel join
23
1
Inner Join : ->join('contacts', 'users.id', '=', 'contacts.user_id')
2
Left Join : ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
3
Right Join : ->rightJoin('posts', 'users.id', '=', 'posts.user_id')
4
Cross Join : ->crossJoin('colors')
5
6
Advance Queries :
7
-----------------
8
->join('contacts', function ($join) {
9
$join->on('users.id', '=', 'contacts.user_id')
10
->where('contacts.user_id', '>', 5);
11
})
12
laravel join
6
1
use Illuminate\Support\Facades\DB;
2
3
$users = DB::table('users')
4
->join('contacts', 'users.id', '=', 'contacts.user_id')
5
->join('orders', 'users.id', '=', 'orders.user_id')
6
->select('users.*', 'contacts.phone', 'orders.price')
7
->get();
Source: laravel.com
laravel join
8
1
$users = DB::table('users')
2
->join('contacts', 'users.id', '=', 'contacts.user_id')
3
->join('orders', 'users.id', '=', 'orders.user_id')
4
->select('users.*', 'contacts.phone', 'orders.price')
5
->get();
Source: laravel.com
laravel not in query
7
1
DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
parametre grouping laravel quert
1
1
DB::table('users')
2
->where('name', '=', 'John')
3
->where(function ($query) {
4
$query->where('votes', '>', 100)
5
->orWhere('title', '=', 'Admin');
6
})
7
->get();
join in laravel
1
1
$subCategories = Subcategory::join('categories', 'subcategories.category_id', '=', 'categories.id')
2
->select('subcategories.*', 'categories.name AS cname')
3
->orderBy('id', 'desc')
4
->get();
5
0 comments:
Post a Comment
Thanks