Laravel Select() and Get() method and differences

Created At: 2023-05-08 03:22:57 Updated At: 2023-05-08 04:08:30

Laravel Select() and Get() method and differences. Sometimes we get confused how to use select() and get() method or Laravel eloquent.

Select() method

select() method select bunch of columns of your eloquent or database table. It does not return anything. It's just select. So if you use like below

It will just return empty response. See the below picture

So now, we understand select() will not return anyting without get() method. 

Get() method

get() method is more powerful than select() method. It can return all the rows from the eloquent or database table. This method can work alone with select() method. See the get() method, inside it you can mention the database columns just like select() method.

And now see the response

From this we understand you can work without select() method.


get() returns a collection of rows, you may mention colmun inside it

select() just select columns inside a row

With get() method, you also choose to skip any column names, then it will return all the columns from the database row.


Add Reviews