no, get() is like get query result, select() - select specific columns
select() and get() difference
I wonder what the difference between get() and select() is.
I am using ->paginate(15); to paginate my result but I only need a few specific fields.
It got not work with ->get('some_field', 'another_field'); but when I do >select('some_field', 'another_field'); it will work.
Is not get() the same as select ?
@kiwo123 the select method is used to set the columns to be selected, it is like just adding the select clause to the query. Whereas get executes the query as whole select statment and retreives the result. However the columns you set using the select get the higher preority and will not be replaced by following get call. I suggest you to run the following query on your user model and see for yourself ( L53 ):
DB::table('users')->select(['name'])->get(['id','email']);
Usamn.
Please or to participate in this conversation.