How to Do following Query in Laravel Eloquent?
SELECT catID, catName, imgPath FROM categories WHERE catType = "Root"
I have tried following
CategoryModel::where('catType', '=', 'Root')
->lists('catName', 'catID', 'imgPath');
but its return only two fields.
Array ( [7] => Category 1 )
lists()
turns the resulting collection into an array with key value. You can only have two database columns in there. Otherwise you have to useselect()
but then you will get a collection of models not just an array.