add extra elements

Estimated reading time: 1 minute

add extra elements

$roles['y'] = 'y';
$posts->map(function ($post) {
    $post['url'] = 'http://your.url/here';
    return $post;
});
  • loop inside loop add exta
$permissons[$key]{'hasPermissionThisRole'} = $hasPermission ;
  • access object by $me{'name'}

tips and resource

  • https://tutsforweb.com/15-laravel-collection-methods/