Daxsis
3 months ago
610
10
Eloquent

Model select from json column returns `json_unquote..`

Posted 3 months ago by Daxsis

Hello everybody, long time lurker and found some awesome answers, however this time I encountered what seems unusual problem. My setup: Laravel 6.16 Mysql 8.0.19

I have an Activity table and model with json column name and when I try to query it I get this

>>> App\Activity::whereIn('id', [16,25,50])->get(['id', 'name->en'])
=> Illuminate\Database\Eloquent\Collection {#3034
     all: [
       App\Activity {#3035
         id: 16,
         json_unquote(json_extract(`name`, '$."en"')): "8844ge32v",
       },
       App\Activity {#3036
         id: 25,
         json_unquote(json_extract(`name`, '$."en"')): "21972qf55",
       },
       App\Activity {#3037
         id: 50,
         json_unquote(json_extract(`name`, '$."en"')): "700z48306",
       },
     ],
   }

Please sign in or create an account to participate in this conversation.