diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index e6697b091bbd..5e1562f33a5b 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -4,6 +4,7 @@ use ReflectionClass; use ReflectionProperty; +use BadMethodCallException; use Illuminate\Support\Str; use Illuminate\Support\Collection; use Illuminate\Container\Container; @@ -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."); + } }