Use merge helper to create collection with custom data manually in Laravel
Sometimes you need to add some extra collection to another paginate collect. So you can follow this way with merge helper ๐
$books = Book::where('user_id','1')->paginate(3);
$customData = collect(['my_custom_data' => 'Put your custom data here']);
$data = $customData->merge($books);
return response()->json($data);