0
I have to return a json that displays a Person object that contains Another Experience object. I’m using hasMany in Model Person and returning Json that way:
$person = $this->model->with('experiences')->find($id);
return response()->json($person, Response::HTTP_OK);
and I get back Json:
{
"name": "João",
"last_name": "Antonio",
"experiences": [
{
"date_start": "2019-02-01",
"date_end": "2019-03-04",
"description": "Descrição"
}
]
}
I need to return a "date" field that contains the date_start and date_end field in the following format:
{
"name": "João",
"last_name": "Antonio",
"experiences": [
{
"date": "February 2019 - March 2019",
"description": "Descrição"
}
]
}
Thanks, it worked out great
– ernande junior