// ПОГАНО: Завантажує все включаючи великі текстові поля
$posts = Post::where('published', true)->get();
// ДОБРЕ: Тільки потрібні колонки
$posts = Post::select('id', 'title', 'slug', 'published_at')
->where('published', true)
->get();
// Приклад API відповіді
public function index()
{
return Post::select([
'id',
'title',
'slug',
'excerpt',
'published_at',
])
->with('author:id,name,avatar')
->where('published', true)
->paginate(20);
}
// Dropdown/автозаповнення
$users = User::select('id', 'name')
->where('active', true)
->get();
// Зі зв'язками - вказуй колонки для обох
$posts = Post::select('id', 'title', 'author_id')
->with('author:id,name')
->get();