I have a laravel model Course and there is an attribute times has a JSON string (time table to be clear).
when I request the data in controller $courses = Course::all()
I want to parse the times
attribute automatically to array, this is because when I return $courses as JSON it will format the times
to json and it is already JSON so it return non understandable string format, so I need times
to json_decode or to parse to array.
Is there any way to do that in the model or in the controller ??
I can do that by foreach on the $courses
and reformat the times
, but I think there must be another simple solution ...