eloquent get only some columns 1

eloquent get only some columns

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

Here is what the above code is Doing:
1. We’re selecting the name and surname columns from the users table.
2. We’re adding a where clause to the query, so it only fetches the row where the id column is equal to one.
3. We’re using the get method to return the results.

Similar Posts