Iam trying to attach a new value in the API response
$notifications = Auth::user()->notifications()->paginate(env('RECORDS_PER_PAGE'));
return $notifications;
Now i need to attach module_url as a new param with the existing response the above response looks like
{
"current_page": 1,
"data": [
{
"id": "xxxxxxxxxxxxxxxxxxxxxxx",
"type": "App\Notifications\ActivityReminderNotification",
"notifiable_type": "App\Models\User",
"notifiable_id": "xxxxx",
"data": {
"module": "activities",
"module_id": "xxxxx",
"message": "Hi there, an activity has been overdue"
},
"read_at": null,
"created_at": "2019-08-27 18:12:29",
"updated_at": "2019-08-27 18:12:29"
},
{
"id": "xxxxxxxxxxxxxxxxxxxxxxxx",
"type": "App\Notifications\ActivityReminderNotification",
"notifiable_type": "App\Models\User",
"notifiable_id": "xxxxx",
"data": {
"module": "activities",
"module_id": "xxxxx",
"message": "Hi there, an activity has been overdue"
},
"read_at": null,
"created_at": "2019-08-27 16:46:54",
"updated_at": "2019-08-27 16:46:54"
}
],
"first_page_url": "http://domain_url/notifications?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://domain_url/notifications?page=1",
"next_page_url": null,
"path": "http://domain_url/notifications",
"per_page": "10",
"prev_page_url": null,
"to": 2,
"total": 2
}
How can i attach the module_url if i use foreach and split as array then i can't get the pagination for this, can anyone please help me to solve this one.