Data transformations in Laravel using collections and helper functions
When developing not trivial application it often happens that we need to make some data transformations. Let’s assume we we have user and address and we create API and want to data come in the following format:
1 2 3 4 5 6 7 8 9 |
[ 'name' => 'John', 'surname' => 'Doe', 'address' => [ 'street' => 'Street', 'zipcode' => '23123', 'city' => 'Some city', ] ] |
but in database we don’t want to create separate table and put address fields in user table … [Read more…]