Laravel - When to use ->get()

后端 未结 5 1916
悲哀的现实
悲哀的现实 2021-02-07 03:06

I\'m confused as to when ->get() in Laravel...

E.G. DB::table(\'users\')->find(1) doesn\'t need ->get() to retrieve the results, neither

5条回答
  •  不知归路
    2021-02-07 03:28

    Basically what you need to understand is that get() return a collection(note that one object can be in the collection but it still a collection) why first() returns the first object from the result of the query(that is it returns an object) #Take_away Get() return a collection first() return an object

提交回复
热议问题