1Arr::add()
2The Arr::add method adds a given key / value pair to an array if the given key doesn't already exist in the array or is set to null:
3
4use Illuminate\Support\Arr;
5
6$array = Arr::add(['name' => 'Desk'], 'price', 100);
7
8// ['name' => 'Desk', 'price' => 100]
9
10$array = Arr::add(['name' => 'Desk', 'price' => null], 'price', 100);
11
12// ['name' => 'Desk', 'price' => 100]