Complete the code to perform a basic inner join between 'users' and 'posts' tables.
$users = DB::table('users') ->[1]('posts', 'users.id', '=', 'posts.user_id') ->get();
The join method performs an inner join between tables.
Complete the code to perform a left join between 'users' and 'profiles' tables.
$users = DB::table('users') ->[1]('profiles', 'users.id', '=', 'profiles.user_id') ->get();
The leftJoin method returns all records from the left table and matched records from the right table.
Fix the error in the join condition to correctly join 'orders' and 'customers' tables.
$orders = DB::table('orders') ->join('customers', 'orders.customer_id', [1], 'customers.id') ->get();
The join condition uses a single equals sign '=' to compare columns.
Fill both blanks to perform a right join between 'products' and 'categories' tables with correct join condition.
$products = DB::table('products') ->[1]('categories', 'products.category_id', [2], 'categories.id') ->get();
The rightJoin method is used for right joins, and '=' is the correct operator for join conditions.
Fill all three blanks to create a join with an additional where clause filtering 'status' in 'tasks' table.
$tasks = DB::table('tasks') ->[1]('users', 'tasks.user_id', [2], 'users.id') ->where('tasks.status', [3]) ->get();
The code uses join with '=' for the join condition and filters tasks with status 'completed'.