From 42248fb8964407b6f2966f2bf90a90de2ab51e1c Mon Sep 17 00:00:00 2001 From: Daniel Coulbourne Date: Tue, 3 Apr 2018 08:56:35 -0400 Subject: [PATCH] Make Illuminate\View\View Macroable. (#23787) * Make Illuminate\View\View Macroable. * Update to use __call as macroCall to avoid conflict. --- src/Illuminate/View/View.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Illuminate/View/View.php b/src/Illuminate/View/View.php index be51cdc11c59..629b71a1a168 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,10 @@ class View implements ArrayAccess, ViewContract { + use Macroable { + __call as macroCall; + } + /** * The view factory instance. * @@ -395,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