Consider that my table in the DB has many columns. But for a specific query I do not need all of them. How would I do it in Laravel (using both Eloquent and QueryBuilder to get just the columns I need?
Consider that my table in the DB has many columns. But for a specific query I do not need all of them. How would I do it in Laravel (using both Eloquent and QueryBuilder to get just the columns I need?
To define the columns you want to select use select :
DB::table('nome_da_tabela')->select('coluna1', 'coluna2')->get();
As you'll find in the documentation .