How to Select Certain Fields in Laravel Eloquent?

后端 未结 5 843
野性不改
野性不改 2021-01-04 10:09

How to Do following Query in Laravel Eloquent?

SELECT catID, catName, imgPath FROM categories WHERE catType = \"Root\"

I have tried followi

5条回答
  •  不知归路
    2021-01-04 10:37

    From laravel version 5.3^ lists() is deprecated and function pluck() is used instead.

    pluck() returns a collection and if you need a simple array just prepend ->toArray() to it.

提交回复
热议问题