dimanche 3 juillet 2016

how to select specific columns in laravel eloquent

maybe its a dummy question) Lets say i have 7 columns in table, and i want to select only two of them, something like this

SELECT `name`,`surname` FROM `table` WHERE `id` = '1';

In laravel eloquent model it may looks like this

Table::where('id', 1)->get();

but i guess this expression will select ALL columns where id equals 1, and i want only two columns(name, surname), not all. the question is - how to select only two columns?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire