Complete the code to select all users with active status using Eloquent.
$users = User::where('status', [1])->get();
We want to get users whose status is 'active', so the correct value is 'active'.
Complete the code to eager load the 'posts' relationship to optimize queries.
$users = User::with([1])->get();
Eager loading 'posts' reduces the number of queries when accessing user posts.
Fix the error in the query to count users with more than 5 posts.
$count = User::has('posts', '>', [1])->count();
The condition requires counting users with more than 5 posts, so the number is 5.
Fill both blanks to optimize the query by selecting only 'id' and 'name' columns.
$users = User::select([1], [2])->get();
Selecting only 'id' and 'name' reduces data load and speeds up the query.
Fill all three blanks to build a query that filters users by age, orders by name, and limits results.
$users = User::where('age', '>', [1])->orderBy([2], [3])->get();
This query gets users older than 18, orders them by name ascending, and retrieves the results.