From 1f0a6f61f36ab3b9000c4831a3685790a03a7a6f Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Wed, 31 Jul 2019 07:59:34 -0400 Subject: [PATCH] Add array support to withViewData() Closes #49 --- src/Response.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Response.php b/src/Response.php index 771c943f..a2d60e7c 100644 --- a/src/Response.php +++ b/src/Response.php @@ -33,9 +33,13 @@ public function with($key, $value = null) return $this; } - public function withViewData($key, $value) + public function withViewData($key, $value = null) { - $this->viewData[$key] = $value; + if (is_array($key)) { + $this->viewData = array_merge($this->viewData, $key); + } else { + $this->viewData[$key] = $value; + } return $this; }