Eloquent get only one column as an array

前端 未结 5 2075
时光说笑
时光说笑 2020-12-08 01:39

How to get only one column as one dimentional array in laravel 5.2 using eloquent?

I have tried:

$array = Word_relation::select(\'word_two\')->wh         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 02:07

    If you receive multiple entries the correct method is called lists.

        Word_relation::select('word_two')->where('word_one', $word_id)->lists('word_one')->toArray();
    

提交回复
热议问题