skip to Main Content

Array key on laravel controller group by

I want to get data plan by date, then I use carbon on laravel to get it. this my query on laravel controller $data = DB::table('visit_plan') ->join('outlets', 'outlets.id', '=', 'visit_plan.id_outlet') ->select('outlets.id', 'outlets.name') ->get() ->groupBy(function($date) { return $this->attributes['date'] = Carbon::parse($date->date)->format('Y-m-d'); });…

VIEW QUESTION

Postgresql, json, query

I want the syntax to query in postgresql for the data in Json format of the following form into tabular format. data(JSON): 1. { "attr1":"v1", "attr2":[{"subattr":"a1","subattr2":"aa1"},{"subattr":"a2","subattr2":"aa2"}],"attr3":"vv1"} 2. { "attr1":"v2", "attr2":[{"subattr":"b1","subattr2":"bb1"},{"subattr":"b2","subattr2":"bb2"},{"subattr":"b3","subattr2":"bb3"}],"attr3":"vv2"} I am stuck with querying the elements in the "attr2".…

VIEW QUESTION
Back To Top
Search