Skip to content

Commit

Permalink
Allow simple messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey McCormick committed Aug 1, 2015
1 parent 289cd9b commit 2b1f135
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,25 @@ The first parameter is the view file that you would like to use. The second is

#### Send

The `send` method sends the SMS through the configured driver.
The `send` method sends the SMS through the configured driver using a Laravel view file.

SMS::send($view, Array $data, function($sms) {
$sms->to('+15555555555');
}
SMS::send('simple-sms::welcome', $data, function($sms) {
$sms->to('+15555555555');
});

It is possible to send a simple message without creating views by passing a string instead of a view.

SMS::send($message, [], function($sms) {
$sms->to('+15555555555');
}
SMS::send('This is my message', [], function($sms) {
$sms->to('+15555555555');
});

>The simple message format is only supported on Laravel 5.
#### Queue

Expand Down
15 changes: 13 additions & 2 deletions src/SimpleSoftwareIO/SMS/OutgoingMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,24 @@ public function __construct(Factory $views)
}

/**
* Constructs a message with its view file
* Composes a message.
*
* @return \Illuminate\View\Factory
*/
public function composeMessage()
{
return $this->views->make($this->view, $this->data)->render();
/**
* Attempts to make a view.
* If a view can not be created; it is assumed that simple message is passed through.
*/
try
{
return $this->views->make($this->view, $this->data)->render();
}
catch(\InvalidArgumentException $e)
{
return $this->view;
}
}

/**
Expand Down

0 comments on commit 2b1f135

Please sign in to comment.