You can use json_decode(Your variable Name)
:
json_decode($result)
I was getting value from Model.where a column has value like this way
{"dayList":[
{"day":[1,2,3,4],"time":[{"in_time":"10:00"},{"late_time":"15:00"},{"out_time":"16:15"}]
},
{"day":[5,6,7],"time":[{"in_time":"10:00"},{"late_time":"15:00"},{"out_time":"16:15"}]}
]
}
so access this value form model. you have to use this code.
$dayTimeListObject = json_decode($settingAttendance->bio_attendance_day_time,1);
foreach ( $dayTimeListObject['dayList'] as $dayListArr)
{
foreach ( $dayListArr['day'] as $dayIndex)
{
if( $dayIndex == Date('w',strtotime('2020-02-11')))
{
$dayTimeList= $dayListArr['time'];
}
}
}
return $dayTimeList[2]['out_time'] ;
You can also define caste in your Model file.
protected $casts = [
'your-column-name' => 'json'
];
so after this no need of this line .
$dayTimeListObject = json_decode($settingAttendance->bio_attendance_day_time,1);
you can directly access this code.
$settingAttendance->bio_attendance_day_time