From 5e2373817d882e9873f3ba21da56c117f890599d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 25 Jun 2012 21:31:54 +0300 Subject: [PATCH] Allow for passing variables to views with more expressive method calls. Example: with_foo($bar) instead of with('foo', $bar) Signed-off-by: Franz Liedke --- laravel/view.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/laravel/view.php b/laravel/view.php index 9a375073..2754d495 100644 --- a/laravel/view.php +++ b/laravel/view.php @@ -551,4 +551,20 @@ class View implements ArrayAccess { return $this->render(); } + /** + * Magic Method for handling dynamic functions. + * + * This method handles calls to dynamic with helpers. + */ + public function __call($method, $parameters) + { + if (strpos($method, 'with_') === 0) + { + $key = substr($method, 5); + return $this->with($key, $parameters[0]); + } + + throw new \Exception("Method [$method] is not defined on the View class."); + } + } \ No newline at end of file