Skip to content

Commit

Permalink
[5.3] Added with* to Mailable (#15316)
Browse files Browse the repository at this point in the history
* Added with* to Mailable

* Fix ordering of imports
  • Loading branch information
jbrooksuk authored and taylorotwell committed Sep 7, 2016
1 parent e68358d commit ae86295
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ReflectionClass;
use ReflectionProperty;
use BadMethodCallException;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Container\Container;
Expand Down Expand Up @@ -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.");
}
}

0 comments on commit ae86295

Please sign in to comment.