1

I'm trying to add an attribute to be passed in data but I would like all other attributes to stay.

$data = $request->all();

Is it possible to do this:

$data =[...data, 'Total'=> $total]

I think that ...data is for javascript. Is there an equivalent in laravel?

Also James
  • 21
  • 4
  • 1
    Does [php-spread-syntax-in-array-declaration](https://stackoverflow.com/questions/45419150/php-spread-syntax-in-array-declaration) answer? – Juan Eizmendi Jul 21 '21 at 04:09
  • 1
    Does this answer your question? [PHP Spread Syntax in Array Declaration](https://stackoverflow.com/questions/45419150/php-spread-syntax-in-array-declaration) – John Lobo Jul 21 '21 at 04:11
  • Yes thank you so much! I will test it out in a few. – Also James Jul 21 '21 at 05:01

0 Answers0