How to Add Additional Data to The Resource JSON Response in Laravel
In this lesson, we will see how to add additional data to the resource JSON response in Laravel, let's assume that we want once we store a new user we return the user resource with a success message.
Add additional data to the resource JSON response in Laravel
So to do that check the code below:
return UserResource::make($user)->additional([
'message' => 'Account created successfully'
]);