Laravel developers tips

Helpful solutions for Laravel framework developers

array_dot

Data transformations in Laravel using collections and helper functions

December 28, 2016 by Marcin Nabiałek / Leave a Comment

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:

Data 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…]

Posted in: Laravel, PHP, Request Tagged: array_dot, array_set, collections, data transformation, keyby

Marcin Nabiałek

Marcin Nabiałek - Certified Laravel Developer
Marcin Nabiałek - Zend Certified PHP Engineer

Categories

  • Composer
  • Eloquent
  • Laravel
  • Laravel Blade
  • Laravel Dusk
  • Laravel packages
  • Mockery
  • PHP
  • PhpUnit
  • Request
  • Testing
  • Validation

Copyright © 2025 Marcin Nabiałek