From 3ea9f4237e4d7e1d3105b95b476db712111d8993 Mon Sep 17 00:00:00 2001 From: Daniel Coulbourne Date: Mon, 2 Apr 2018 16:14:08 -0400 Subject: [PATCH 1/2] Make Illuminate\View\View Macroable. --- src/Illuminate/View/View.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index be51cdc11c59..66007ef07128 100755 --- a/src/Illuminate/View/View.php +++ b/src/Illuminate/View/View.php @@ -9,6 +9,7 @@ use Illuminate\Support\Str; use Illuminate\Support\MessageBag; use Illuminate\Contracts\View\Engine; +use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Renderable; use Illuminate\Contracts\Support\MessageProvider; @@ -16,6 +17,8 @@ class View implements ArrayAccess, ViewContract { + use Macroable; + /** * The view factory instance. * From 976b56755b7410809a7595cfd3343084d5e31200 Mon Sep 17 00:00:00 2001 From: Daniel Coulbourne Date: Mon, 2 Apr 2018 17:04:34 -0400 Subject: [PATCH 2/2] Update to use __call as macroCall to avoid conflict. --- src/Illuminate/View/View.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index 66007ef07128..629b71a1a168 100755 --- a/src/Illuminate/View/View.php +++ b/src/Illuminate/View/View.php @@ -17,7 +17,9 @@ class View implements ArrayAccess, ViewContract { - use Macroable; + use Macroable { + __call as macroCall; + } /** * The view factory instance. @@ -398,6 +400,10 @@ public function __unset($key) */ public function __call($method, $parameters) { + if (static::hasMacro($method)) { + return $this->macroCall($method, $parameters); + } + if (! Str::startsWith($method, 'with')) { throw new BadMethodCallException(sprintf( 'Method %s::%s does not exist.', static::class, $method