How to take all of the Request and add 1 field at the Insert in Laravel 5.3?

This code takes:
$product = new Product($request->all());
You can of course break, to take all of the type:
$product = new Product([
'name' => $request->name,
'description' => $request->name,
...
]);

Or do 2 a request for preservation.
Only then will a lot of the visual code, I would like to facilitate.
How can I get $request->all() + else option and create a data object?
July 2nd 19 at 13:35
2 answers
July 2nd 19 at 13:37
Solution
$data = $request->all();

$data['key'] = 'value';

$product = new Product($data);
thanks - jaycee commented on July 2nd 19 at 13:40
July 2nd 19 at 13:39
Solution
Product::create($request->all() + ['key' => 'value']);
: well, XS, this Vario sales not tried. Although the idea should work. - jaycee commented on July 2nd 19 at 13:42
Besides the entry of Alexei, the more clear to me. - jaycee commented on July 2nd 19 at 13:45

Find more questions by tags PHPLaravel