Complete the code to select all records from the 'users' table using Laravel's query builder.
$users = DB::table('users')->[1]();
The get() method retrieves all records from the query builder in Laravel.
Complete the code to select only the 'name' and 'email' columns from the 'users' table.
$users = DB::table('users')->[1](['name', 'email'])->get();
The select() method specifies which columns to retrieve in Laravel's query builder.
Fix the error in the code to get the first user with id 5.
$user = DB::table('users')->where('id', [1])->first();
The where method expects the actual value without quotes for integers. Using 5 (integer) is correct.
Fill both blanks to select users where 'status' is 'active' and order by 'created_at' descending.
$users = DB::table('users')->where('status', [1])->orderBy([2], 'desc')->get();
The where method needs the value 'active' for status, and orderBy needs the column name 'created_at' to sort by date.
Fill all three blanks to select 'name' and 'email' of users older than 18, ordered by 'name' ascending.
$users = DB::table('users')->select([1], [2])->where('age', '>', [3])->orderBy('name', 'asc')->get();
The select method needs the column names 'name' and 'email'. The where clause compares 'age' to the number 18.