Skip to content
Advertisement

retrieve single row in LARAVELusing eloquent

i am using laravel 5.1 and want to retrieve a single row in the database then manipulate it after.

my current code is

JavaScript

why cant i do it like this?

JavaScript

am i using a wrong function or something? thanks in advance.

Advertisement

Answer

Try this:

JavaScript

When you are using get(), it returns an array of Std class object.

In addition to retrieving all of the records for a given table, you may also retrieve single records using first. Instead of returning a collection of models, these methods return a single model instance:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement