Laravel: getting a a single value from a MySQL query

前端 未结 6 1791
[愿得一人]
[愿得一人] 2021-02-03 17:27

I\'m trying get a single value from MySQL database using laravel but the problem I\'m getting an array . this is my query result in MySQL command line:

select gr         


        
6条回答
  •  悲哀的现实
    2021-02-03 18:05

    On laravel 5.6 it has a very simple solution:

    User::where('username', $username)->first()->groupName;
    

    It will return groupName as a string.

提交回复
热议问题