From 42349f88087009b221987604ee25c3570fc6a305 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Wed, 7 Sep 2016 10:00:28 +0100 Subject: [PATCH 1/2] Added with* to Mailable --- src/Illuminate/Mail/Mailable.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index e6697b091bbd..48b1c2769a6f 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -2,6 +2,7 @@ namespace Illuminate\Mail; +use BadMethodCallException; use ReflectionClass; use ReflectionProperty; use Illuminate\Support\Str; @@ -484,4 +485,22 @@ public function withSwiftMessage($callback) return $this; } + + /** + * Dynamically bind parameters to the message. + * + * @param string $method + * @param array $parameters + * @return $this + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (Str::startsWith($method, 'with')) { + return $this->with(Str::snake(substr($method, 4)), $parameters[0]); + } + + throw new BadMethodCallException("Method [$method] does not exist on mailable."); + } } From bd5f19e8d9353e8475a511cd913d92786a30fe18 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Wed, 7 Sep 2016 10:37:56 +0100 Subject: [PATCH 2/2] Fix ordering of imports --- src/Illuminate/Mail/Mailable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 48b1c2769a6f..5e1562f33a5b 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -2,9 +2,9 @@ namespace Illuminate\Mail; -use BadMethodCallException; use ReflectionClass; use ReflectionProperty; +use BadMethodCallException; use Illuminate\Support\Str; use Illuminate\Support\Collection; use Illuminate\Container\Container;